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.
This commit is contained in:
Sam 2014-06-25 09:45:12 +10:00
parent f8f0fb15e3
commit bbca684f6d
1 changed files with 9 additions and 0 deletions

View File

@ -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