UX: Publish topic changes when topic is published.
This commit is contained in:
parent
48a9860f07
commit
690d2f4bd3
|
@ -868,7 +868,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||
|
||||
const refresh = (args) => this.appEvents.trigger('post-stream:refresh', args);
|
||||
|
||||
this.messageBus.subscribe("/topic/" + this.get('model.id'), data => {
|
||||
this.messageBus.subscribe(`/topic/${this.get('model.id')}`, data => {
|
||||
const topic = this.get('model');
|
||||
|
||||
if (data.notification_level_change) {
|
||||
|
@ -878,6 +878,17 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||
}
|
||||
|
||||
const postStream = this.get('model.postStream');
|
||||
|
||||
if (data.reload_topic) {
|
||||
topic.reload().then(() => {
|
||||
this.send('postChangedRoute', topic.get('post_number') || 1);
|
||||
this.appEvents.trigger('header:update-topic', topic);
|
||||
if (data.refresh_stream) postStream.refresh();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (data.type) {
|
||||
case "acted":
|
||||
postStream.triggerChangedPost(data.id, data.updated_at).then(() => refresh({ id: data.id, refreshLikes: true }));
|
||||
|
@ -915,12 +926,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||
}
|
||||
}
|
||||
|
||||
if (data.reload_topic) {
|
||||
topic.reload().then(() => {
|
||||
this.send('postChangedRoute', topic.get('post_number') || 1);
|
||||
this.appEvents.trigger('header:update-topic', topic);
|
||||
});
|
||||
} else {
|
||||
if (topic.get('isPrivateMessage') &&
|
||||
this.currentUser &&
|
||||
this.currentUser.get('id') !== data.user_id &&
|
||||
|
@ -937,7 +942,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
|||
this._scrollToPost(data.post_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -376,9 +376,8 @@ const Topic = RestModel.extend({
|
|||
},
|
||||
|
||||
reload() {
|
||||
const self = this;
|
||||
return ajax('/t/' + this.get('id'), { type: 'GET' }).then(function(topic_json) {
|
||||
self.updateFromJson(topic_json);
|
||||
return ajax(`/t/${this.get('id')}`, { type: 'GET' }).then(topic_json => {
|
||||
this.updateFromJson(topic_json);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ module Jobs
|
|||
topic.change_category_to_id(topic_status_update.category_id)
|
||||
topic.update_columns(visible: true)
|
||||
end
|
||||
|
||||
MessageBus.publish("/topic/#{topic.id}", reload_topic: true, refresh_stream: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,9 @@ RSpec.describe Jobs::PublishTopicToCategory do
|
|||
it 'should publish the topic to the new category correctly' do
|
||||
Timecop.travel(1.hour.ago) { topic.update!(visible: false) }
|
||||
|
||||
message = MessageBus.track_publish do
|
||||
described_class.new.execute(topic_status_update_id: topic.topic_status_update.id)
|
||||
end.first
|
||||
|
||||
topic.reload
|
||||
expect(topic.category).to eq(another_category)
|
||||
|
@ -49,5 +51,8 @@ RSpec.describe Jobs::PublishTopicToCategory do
|
|||
%w{created_at bumped_at updated_at last_posted_at}.each do |attribute|
|
||||
expect(topic.public_send(attribute)).to be_within(1.second).of(Time.zone.now)
|
||||
end
|
||||
|
||||
expect(message.data[:reload_topic]).to be_present
|
||||
expect(message.data[:refresh_stream]).to be_present
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue