Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endTracking() fails #1

Open
fsebbah opened this issue Jul 11, 2018 · 5 comments
Open

endTracking() fails #1

fsebbah opened this issue Jul 11, 2018 · 5 comments

Comments

@fsebbah
Copy link

fsebbah commented Jul 11, 2018

Hi,
I have at the point 3.2 When the exercices are finished, in the workout-history-tracker.services, the function endTracking() fails because : this.currentWorkoutLog is null

If I log the finish function : there are a record:
finish this.currentWorkoutLog {"startedOn":"2018-07-11T12:23:11.776Z","completed":false,"exercicesDone":12,"lastExercise":"Side Plank"}

After te router [finish] is called but it seems the startExerciseTimeTracking is called again a second times on the window.setInterval and now the this.currentWorkoutLog = null

And it's not possible to get the route /finish.
To resolve this problem, I add if(this.currentWorkoutLog === null) return false.
And it works.
Thanks,
Franck

@chandermani
Copy link
Owner

HI Frank, I will check and confirm.

@chandermani
Copy link
Owner

I believe this happened because you pressed the browser back button and the code is not destroying the setInterval object in ngDestroy. Can you update the ngDestroy function to

ngOnDestroy() {
    if (this.exerciseTrackingInterval) clearInterval(this.exerciseTrackingInterval);
    this.tracker.endTracking(false);
  }

And try

@chandermani
Copy link
Owner

Added this check to repo too 0f0a130.

@Bigbhardwaj
Copy link

Even after applying ngDestroy() it still persists :

image

@bartduisters
Copy link

endTracking(completed: boolean) {
    if (this.currentWorkoutLog) {
      this.currentWorkoutLog.completed = completed;
      this.currentWorkoutLog.endedOn = new Date();
      this.currentWorkoutLog = null;
    }
    this.workoutTracked = false;
  }

The above code is a workaround so you can move on with the code/book. It seems that the endTracking gets called twice, the second time this.currentWorkoutLog is null -> throws the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants