From eeb508bd9241fa4a56d31b614b3ba22936440112 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Wed, 2 Sep 2015 19:40:50 +0900 Subject: [PATCH 2/2] =?UTF-8?q?activity:=20show=5Fone=20=E3=81=AE=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/plugin/activity/activity.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/core/plugin/activity/activity.rb b/core/plugin/activity/activity.rb index b45a040..cee8f3a 100644 --- a/core/plugin/activity/activity.rb +++ b/core/plugin/activity/activity.rb @@ -66,16 +66,10 @@ Plugin.create(:activity) do # ==== Return # 初めて表示するキーなら真 def show_once(event, *ids) - @show_once ||= Hash.new{ |h, k| h[k] = [] } - result = [] - ids.each_with_index{ |id, index| - storage = @show_once[event][index] ||= Set.new - if storage.include? id - result << true - else - storage << id - result << false end } - not result.all? end + @show_once ||= Set.new + result = @show_once.member?(ids) + @show_once << ids + !result end # アクティビティの古い通知を一定時間後に消す def reset_activity(model) -- 2.5.1