FIX: posts weren't being marked as last read correctly
This commit is contained in:
parent
4331bba549
commit
f5d6b41f91
|
@ -38,7 +38,8 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
topicController.setProperties({
|
topicController.setProperties({
|
||||||
currentPost: closest,
|
currentPost: closest,
|
||||||
progressPosition: closest
|
progressPosition: closest,
|
||||||
|
enteredAt: new Date().getTime()
|
||||||
});
|
});
|
||||||
|
|
||||||
if (topic.present('draft')) {
|
if (topic.present('draft')) {
|
||||||
|
@ -50,6 +51,8 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
||||||
ignoreIfChanged: true
|
ignoreIfChanged: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,25 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
composerController.set('topic', this.get('topic'));
|
composerController.set('topic', this.get('topic'));
|
||||||
}.observes('composer'),
|
}.observes('composer'),
|
||||||
|
|
||||||
|
enteredTopic: function() {
|
||||||
|
if (this.present('controller.enteredAt')) {
|
||||||
|
var topicView = this;
|
||||||
|
Em.run.schedule('afterRender', function() {
|
||||||
|
topicView.updateBar();
|
||||||
|
topicView.updatePosition();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.observes('controller.enteredAt'),
|
||||||
|
|
||||||
|
didInsertElement: function(e) {
|
||||||
|
this.bindScrolling({debounce: 0});
|
||||||
|
$(window).bind('resize.discourse-on-scroll', function() { topicView.updatePosition(); });
|
||||||
|
|
||||||
|
this.$().on('mouseup.discourse-redirect', '.cooked a, a.track-link', function(e) {
|
||||||
|
return Discourse.ClickTrack.trackClick(e);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// This view is being removed. Shut down operations
|
// This view is being removed. Shut down operations
|
||||||
willDestroyElement: function() {
|
willDestroyElement: function() {
|
||||||
|
|
||||||
|
@ -72,22 +91,6 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
this.set('controller.controllers.header.showExtraInfo', false);
|
this.set('controller.controllers.header.showExtraInfo', false);
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function(e) {
|
|
||||||
this.bindScrolling({debounce: 0});
|
|
||||||
|
|
||||||
var topicView = this;
|
|
||||||
$(window).bind('resize.discourse-on-scroll', function() { topicView.updatePosition(); });
|
|
||||||
|
|
||||||
this.$().on('mouseup.discourse-redirect', '.cooked a, a.track-link', function(e) {
|
|
||||||
return Discourse.ClickTrack.trackClick(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.updatePosition();
|
|
||||||
|
|
||||||
// We want to make sure the progress bar is updated after it's rendered
|
|
||||||
this.updateBar();
|
|
||||||
},
|
|
||||||
|
|
||||||
debounceLoadSuggested: Discourse.debounce(function(){
|
debounceLoadSuggested: Discourse.debounce(function(){
|
||||||
if (this.get('isDestroyed') || this.get('isDestroying')) { return; }
|
if (this.get('isDestroyed') || this.get('isDestroying')) { return; }
|
||||||
|
|
||||||
|
@ -147,12 +150,13 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
|
|
||||||
// Called for every post seen, returns the post number
|
// Called for every post seen, returns the post number
|
||||||
postSeen: function($post) {
|
postSeen: function($post) {
|
||||||
|
|
||||||
var post = this.getPost($post);
|
var post = this.getPost($post);
|
||||||
|
|
||||||
if (post) {
|
if (post) {
|
||||||
var postNumber = post.get('post_number');
|
var postNumber = post.get('post_number');
|
||||||
if (postNumber > (this.get('last_read_post_number') || 0)) {
|
if (postNumber > (this.get('controller.last_read_post_number') || 0)) {
|
||||||
this.set('last_read_post_number', postNumber);
|
this.set('controller.last_read_post_number', postNumber);
|
||||||
}
|
}
|
||||||
if (!post.get('read')) {
|
if (!post.get('read')) {
|
||||||
post.set('read', true);
|
post.set('read', true);
|
||||||
|
|
Loading…
Reference in New Issue