diff --git a/app/models/emoji.rb b/app/models/emoji.rb index f017782a5..8c787e574 100644 --- a/app/models/emoji.rb +++ b/app/models/emoji.rb @@ -20,15 +20,15 @@ class Emoji end def self.all - @all ||= standard | custom + Discourse.cache.fetch("all", family: "emoji") { standard | custom } end def self.standard - @standard ||= load_standard + Discourse.cache.fetch("standard", family: "emoji") { load_standard } end def self.custom - @custom ||= load_custom + Discourse.cache.fetch("custom", family: "emoji") { load_custom } end def self.create_from_path(path) @@ -61,8 +61,7 @@ class Emoji end def self.clear_cache - @custom = nil - @all = nil + Discourse.cache.delete_by_family("emoji") end def self.db_file diff --git a/app/models/emoji_set_site_setting.rb b/app/models/emoji_set_site_setting.rb index 6a5225c67..32221b26d 100644 --- a/app/models/emoji_set_site_setting.rb +++ b/app/models/emoji_set_site_setting.rb @@ -5,6 +5,8 @@ class EmojiSetSiteSetting < EnumSiteSetting # fix the URLs when changing the site setting DiscourseEvent.on(:site_setting_saved) do |site_setting| if site_setting.name.to_s == "emoji_set" && site_setting.value_changed? + Emoji.clear_cache + before = "/images/emoji/#{site_setting.value_was}/" after = "/images/emoji/#{site_setting.value}/"