mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: when entering topics "tracking" would not be set
There was a timing issue when subscribing to messages for topics. Old flow: - We generate JSON for topic - We subscribe to messages for topic New flow: - We keep track of last id in the topic message bus channel - We generate JSON - We subscribe to messages for topic starting at saved message id This ensures that there is complete overlap for message consumption and that there are no cases where an update may go missing due to timing
This commit is contained in:
parent
7821400141
commit
6ddd8d9166
@ -946,7 +946,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||
this._scrollToPost(data.post_number);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, this.get('model.message_bus_last_id'));
|
||||
},
|
||||
|
||||
_scrollToPost: debounce(function(postNumber) {
|
||||
|
@ -7,6 +7,11 @@ export default Discourse.Route.extend({
|
||||
// Avoid default model hook
|
||||
model(params) { return params; },
|
||||
|
||||
deactivate() {
|
||||
this._super();
|
||||
this.controllerFor('topic').unsubscribe();
|
||||
},
|
||||
|
||||
setupController(controller, params) {
|
||||
params = params || {};
|
||||
params.track_visit = true;
|
||||
@ -36,6 +41,8 @@ export default Discourse.Route.extend({
|
||||
enteredAt: new Date().getTime().toString(),
|
||||
});
|
||||
|
||||
topicController.subscribe();
|
||||
|
||||
// Highlight our post after the next render
|
||||
Ember.run.scheduleOnce('afterRender', function() {
|
||||
self.appEvents.trigger('post:highlight', closest);
|
||||
|
@ -189,7 +189,6 @@ const TopicRoute = Discourse.Route.extend({
|
||||
postStream.cancelFilter();
|
||||
|
||||
topicController.set('multiSelect', false);
|
||||
topicController.unsubscribe();
|
||||
this.controllerFor('composer').set('topic', null);
|
||||
this.screenTrack.stop();
|
||||
|
||||
@ -216,7 +215,6 @@ const TopicRoute = Discourse.Route.extend({
|
||||
|
||||
this.controllerFor('composer').set('topic', model);
|
||||
this.topicTrackingState.trackIncoming('all');
|
||||
controller.subscribe();
|
||||
|
||||
// We reset screen tracking every time a topic is entered
|
||||
this.screenTrack.start(model.get('id'), controller);
|
||||
|
@ -61,7 +61,8 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
:tags,
|
||||
:featured_link,
|
||||
:topic_timer,
|
||||
:unicode_title
|
||||
:unicode_title,
|
||||
:message_bus_last_id
|
||||
|
||||
# TODO: Split off into proper object / serializer
|
||||
def details
|
||||
@ -125,6 +126,10 @@ class TopicViewSerializer < ApplicationSerializer
|
||||
result
|
||||
end
|
||||
|
||||
def message_bus_last_id
|
||||
object.message_bus_last_id
|
||||
end
|
||||
|
||||
def chunk_size
|
||||
object.chunk_size
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ require_dependency 'gaps'
|
||||
|
||||
class TopicView
|
||||
|
||||
attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size, :print
|
||||
attr_reader :topic, :posts, :guardian, :filtered_posts, :chunk_size, :print, :message_bus_last_id
|
||||
attr_accessor :draft, :draft_key, :draft_sequence, :user_custom_fields, :post_custom_fields
|
||||
|
||||
def self.slow_chunk_size
|
||||
@ -38,6 +38,7 @@ class TopicView
|
||||
end
|
||||
|
||||
def initialize(topic_id, user=nil, options={})
|
||||
@message_bus_last_id = MessageBus.last_id("/topic/#{topic_id}")
|
||||
@user = user
|
||||
@guardian = Guardian.new(@user)
|
||||
@topic = find_topic(topic_id)
|
||||
|
Loading…
Reference in New Issue
Block a user