From 5b2e7c8d1074e49cd7deac9f6922de07ac4b4ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sat, 26 May 2018 03:11:10 +0200 Subject: [PATCH] fix the build --- app/controllers/application_controller.rb | 2 ++ app/controllers/notifications_controller.rb | 5 +++-- app/models/notification.rb | 10 ++-------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 92d639f65a6..218e04eb46b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -254,6 +254,8 @@ class ApplicationController < ActionController::Base if notifications.present? notification_ids = notifications.split(",").map(&:to_i) Notification.read(current_user, notification_ids) + current_user.reload + current_user.publish_notifications_state cookies.delete('cn') end end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index f20e6b9b13a..7fbc06a2b06 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -59,10 +59,11 @@ class NotificationsController < ApplicationController else Notification.where(user_id: current_user.id).includes(:topic).where(read: false).update_all(read: true) current_user.saw_notification_id(Notification.recent_report(current_user, 1).max.try(:id)) - current_user.reload - current_user.publish_notifications_state end + current_user.reload + current_user.publish_notifications_state + render json: success_json end diff --git a/app/models/notification.rb b/app/models/notification.rb index fc67f394812..c476f778b38 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -58,26 +58,20 @@ class Notification < ActiveRecord::Base end def self.mark_posts_read(user, topic_id, post_numbers) - count = Notification + Notification .where(user_id: user.id) .where(topic_id: topic_id) .where(post_number: post_numbers) .where(read: false) .update_all(read: true) - - refresh_notification_count if count > 0 - - count end def self.read(user, notification_ids) - count = Notification + Notification .where(id: notification_ids) .where(user_id: user.id) .where(read: false) .update_all(read: true) - - refresh_notification_count if count > 0 end def self.interesting_after(min_date)