mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Always ensure notifications are treated as read once clicked
UX: improve messaging so notifications list is far more stable PERF: improve performance of notifcation lookup queries - Add feature "SetTransientHeader" that allows shipping info to server in the next Ajax request - remove local storage hack used for notifications - amend lookupStale to return hydrated objects, move logic into store - stop magically clearing various notifications (likes, invitee accepted, group_summary, granted badge)
This commit is contained in:
@ -33,6 +33,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
before_filter :set_current_user_for_logs
|
||||
before_filter :clear_notifications
|
||||
before_filter :set_locale
|
||||
before_filter :set_mobile_view
|
||||
before_filter :inject_preview_style
|
||||
@ -137,6 +138,28 @@ class ApplicationController < ActionController::Base
|
||||
response.headers["X-Discourse-Route"] = "#{controller_name}/#{action_name}"
|
||||
end
|
||||
|
||||
def clear_notifications
|
||||
if current_user && !Discourse.readonly_mode?
|
||||
|
||||
cookie_notifications = cookies['cn'.freeze]
|
||||
notifications = request.headers['Discourse-Clear-Notifications'.freeze]
|
||||
|
||||
if cookie_notifications
|
||||
if notifications.present?
|
||||
notifications += "," << cookie_notifications
|
||||
else
|
||||
notifications = cookie_notifications
|
||||
end
|
||||
end
|
||||
|
||||
if notifications.present?
|
||||
notification_ids = notifications.split(",").map(&:to_i)
|
||||
Notification.where(user_id: current_user.id, id: notification_ids).update_all(read: true)
|
||||
cookies.delete('cn')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_locale
|
||||
I18n.locale = current_user.try(:effective_locale) || SiteSetting.default_locale
|
||||
I18n.ensure_all_loaded!
|
||||
|
Reference in New Issue
Block a user