correct ScreenTrack so it properly flushes everything that happened on stop and resets on start
This commit is contained in:
parent
cc79d22f82
commit
809594c00a
|
@ -14,6 +14,9 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function(topicId) {
|
start: function(topicId) {
|
||||||
|
|
||||||
|
this.reset();
|
||||||
|
|
||||||
// Create an interval timer if we don't have one.
|
// Create an interval timer if we don't have one.
|
||||||
if (!this.get('interval')) {
|
if (!this.get('interval')) {
|
||||||
var screenTrack = this;
|
var screenTrack = this;
|
||||||
|
@ -31,6 +34,7 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
stop: function() {
|
stop: function() {
|
||||||
|
this.tick();
|
||||||
this.flush();
|
this.flush();
|
||||||
this.reset();
|
this.reset();
|
||||||
this.set('topicId', null);
|
this.set('topicId', null);
|
||||||
|
@ -60,7 +64,6 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
||||||
this.set('timings', {});
|
this.set('timings', {});
|
||||||
this.set('totalTimings', {});
|
this.set('totalTimings', {});
|
||||||
this.set('topicTime', 0);
|
this.set('topicTime', 0);
|
||||||
this.set('cancelled', false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
scrolled: function() {
|
scrolled: function() {
|
||||||
|
@ -77,6 +80,7 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
||||||
|
|
||||||
// Update our total timings
|
// Update our total timings
|
||||||
var totalTimings = this.get('totalTimings');
|
var totalTimings = this.get('totalTimings');
|
||||||
|
|
||||||
_.each(this.get('timings'), function(timing,key) {
|
_.each(this.get('timings'), function(timing,key) {
|
||||||
if (!totalTimings[timing.postNumber])
|
if (!totalTimings[timing.postNumber])
|
||||||
totalTimings[timing.postNumber] = 0;
|
totalTimings[timing.postNumber] = 0;
|
||||||
|
@ -100,7 +104,6 @@ Discourse.ScreenTrack = Ember.Object.extend({
|
||||||
Discourse.TopicTrackingState.current().updateSeen(topicId, highestSeen);
|
Discourse.TopicTrackingState.current().updateSeen(topicId, highestSeen);
|
||||||
}
|
}
|
||||||
if (!$.isEmptyObject(newTimings)) {
|
if (!$.isEmptyObject(newTimings)) {
|
||||||
|
|
||||||
Discourse.ajax('/topics/timings', {
|
Discourse.ajax('/topics/timings', {
|
||||||
data: {
|
data: {
|
||||||
timings: newTimings,
|
timings: newTimings,
|
||||||
|
|
Loading…
Reference in New Issue