diff --git a/app/assets/javascripts/extra/flash_notifies.js b/app/assets/javascripts/extra/flash_notifies.js index 4002c4873..52c9fbf53 100644 --- a/app/assets/javascripts/extra/flash_notifies.js +++ b/app/assets/javascripts/extra/flash_notifies.js @@ -12,7 +12,6 @@ $(document).ready(function() { } $('#close-alert').click(function () { - setCookie("flash_notify_id", FLASH_NOTIFY_ID, FLASH_EXPIRES_AT); setCookie("flash_notify_hash", FLASH_HASH_ID, FLASH_EXPIRES_AT); }); }); diff --git a/app/models/flash_notify.rb b/app/models/flash_notify.rb index 5cc407173..601b197b2 100644 --- a/app/models/flash_notify.rb +++ b/app/models/flash_notify.rb @@ -18,7 +18,7 @@ class FlashNotify < ActiveRecord::Base read_attribute("body_#{language}") end - def should_show?(cookie_id, cookie_hash_id) - !(cookie_id.to_i == id && cookie_hash_id == hash_id) + def should_show?(cookie_hash_id) + cookie_hash_id != hash_id && published end end diff --git a/app/views/layouts/_notifies.html.haml b/app/views/layouts/_notifies.html.haml index 766485dcd..46f5b8d00 100644 --- a/app/views/layouts/_notifies.html.haml +++ b/app/views/layouts/_notifies.html.haml @@ -1,12 +1,11 @@ - if current_user || APP_CONFIG['anonymous_access'] .flash_notify - flash_notify = FlashNotify.published.first - - if flash_notify && flash_notify.should_show?(cookies[:flash_notify_id], cookies[:flash_notify_hash]) + - if flash_notify && flash_notify.should_show?(cookies[:flash_notify_hash]) .alert{:class => "alert-#{flash_notify.status}"} = flash_notify.body current_user.language %a{:class=>"close", :'data-dismiss'=>"alert", :href=>"#", :id => 'close-alert'} × -:javascript - var FLASH_NOTIFY_ID = "#{flash_notify.id}"; - var FLASH_HASH_ID = "#{flash_notify.hash_id}"; - var FLASH_EXPIRES_AT = "#{Date.today + 1.year}"; + :javascript + var FLASH_HASH_ID = "#{flash_notify.hash_id}"; + var FLASH_EXPIRES_AT = "#{Date.today + 1.year}";