From bbca684f6d8f72acaf612d57a01e1bb0dc44a72d Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 25 Jun 2014 09:45:12 +1000 Subject: [PATCH] BUGFIX: not updating tracking state after entering a topic Occurs in 2 cases: 1. Change "Regular" to "Tracking" other browsers do not update 2. If you are set to track all new topics on enter. --- app/models/topic_user.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/topic_user.rb b/app/models/topic_user.rb index 36d47f77146..1816f34cbe1 100644 --- a/app/models/topic_user.rb +++ b/app/models/topic_user.rb @@ -112,6 +112,13 @@ class TopicUser < ActiveRecord::Base observe_after_save_callbacks_for topic_id, user_id end end + + if attrs[:notification_level] + MessageBus.publish("/topic/#{topic_id}", + {notification_level_change: attrs[:notification_level]}, user_ids: [user_id]) + end + + rescue ActiveRecord::RecordNotUnique # In case of a race condition to insert, do nothing end @@ -210,6 +217,8 @@ class TopicUser < ActiveRecord::Base FROM topic_users AS ftu WHERE ftu.user_id = :user_id and ftu.topic_id = :topic_id)", args) + + MessageBus.publish("/topic/#{topic_id}", {notification_level_change: args[:new_status]}, user_ids: [user.id]) end end