FIX: when no notification state exists on topic, mute on unsubscribe
This commit is contained in:
parent
7ee11b0508
commit
0b6d12f95d
|
@ -121,13 +121,13 @@ class TopicsController < ApplicationController
|
||||||
|
|
||||||
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])
|
tu = TopicUser.find_by(user_id: current_user.id, topic_id: params[:topic_id])
|
||||||
|
|
||||||
if tu.notification_level > TopicUser.notification_levels[:regular]
|
if tu && tu.notification_level > TopicUser.notification_levels[:regular]
|
||||||
tu.notification_level = TopicUser.notification_levels[:regular]
|
tu.notification_level = TopicUser.notification_levels[:regular]
|
||||||
|
tu.save!
|
||||||
else
|
else
|
||||||
tu.notification_level = TopicUser.notification_levels[:muted]
|
TopicUser.change(current_user.id, params[:topic_id].to_i, notification_level: TopicUser.notification_levels[:muted])
|
||||||
end
|
end
|
||||||
|
|
||||||
tu.save!
|
|
||||||
|
|
||||||
perform_show_response
|
perform_show_response
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue