Use notification types instead of target types to clear them
This commit is contained in:
parent
4c67a9b492
commit
54e072c98c
|
@ -4,17 +4,13 @@ class AnswerController < ApplicationController
|
|||
@display_all = true
|
||||
|
||||
if user_signed_in?
|
||||
notif = Notification.where(target_type: "Answer", target_id: @answer.id, recipient_id: current_user.id, new: true).first
|
||||
unless notif.nil?
|
||||
notif.new = false
|
||||
notif.save
|
||||
end
|
||||
notif = Notification.where(target_type: "Comment", target_id: @answer.comments.pluck(:id), recipient_id: current_user.id, new: true)
|
||||
notif = Notification.where(type: "Notification::QuestionAnswered", target_id: @answer.id, recipient_id: current_user.id, new: true).first
|
||||
notif.update(new: false) unless notif.nil?
|
||||
notif = Notification.where(type: "Notification::Commented", target_id: @answer.comments.pluck(:id), recipient_id: current_user.id, new: true)
|
||||
notif.update_all(new: false) unless notif.empty?
|
||||
notif = Notification.where(target_type: "Smile", target_id: @answer.smiles.pluck(:id), recipient_id: current_user.id, new: true)
|
||||
notif = Notification.where(type: "Notification::Smiled", target_id: @answer.smiles.pluck(:id), recipient_id: current_user.id, new: true)
|
||||
notif.update_all(new: false) unless notif.empty?
|
||||
# @answer.comments.smiles throws
|
||||
notif = Notification.where(target_type: "CommentSmile", target_id: @answer.comment_smiles.pluck(:id), recipient_id: current_user.id, new: true)
|
||||
notif = Notification.where(type: "Notification::CommentSmiled", target_id: @answer.comment_smiles.pluck(:id), recipient_id: current_user.id, new: true)
|
||||
notif.update_all(new: false) unless notif.empty?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue