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({
|
||||
currentPost: closest,
|
||||
progressPosition: closest
|
||||
progressPosition: closest,
|
||||
enteredAt: new Date().getTime()
|
||||
});
|
||||
|
||||
if (topic.present('draft')) {
|
||||
|
@ -50,6 +51,8 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
|||
ignoreIfChanged: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,25 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
|||
composerController.set('topic', this.get('topic'));
|
||||
}.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
|
||||
willDestroyElement: function() {
|
||||
|
||||
|
@ -72,22 +91,6 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
|||
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(){
|
||||
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
|
||||
postSeen: function($post) {
|
||||
|
||||
var post = this.getPost($post);
|
||||
|
||||
if (post) {
|
||||
var postNumber = post.get('post_number');
|
||||
if (postNumber > (this.get('last_read_post_number') || 0)) {
|
||||
this.set('last_read_post_number', postNumber);
|
||||
if (postNumber > (this.get('controller.last_read_post_number') || 0)) {
|
||||
this.set('controller.last_read_post_number', postNumber);
|
||||
}
|
||||
if (!post.get('read')) {
|
||||
post.set('read', true);
|
||||
|
|
Loading…
Reference in New Issue