mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 20:34:32 +08:00
FIX: use cache to store custom emoji
This commit is contained in:
parent
45dbdb6896
commit
23aede6eb5
|
@ -20,15 +20,15 @@ class Emoji
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.all
|
def self.all
|
||||||
@all ||= standard | custom
|
Discourse.cache.fetch("all", family: "emoji") { standard | custom }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.standard
|
def self.standard
|
||||||
@standard ||= load_standard
|
Discourse.cache.fetch("standard", family: "emoji") { load_standard }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.custom
|
def self.custom
|
||||||
@custom ||= load_custom
|
Discourse.cache.fetch("custom", family: "emoji") { load_custom }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_from_path(path)
|
def self.create_from_path(path)
|
||||||
|
@ -61,8 +61,7 @@ class Emoji
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.clear_cache
|
def self.clear_cache
|
||||||
@custom = nil
|
Discourse.cache.delete_by_family("emoji")
|
||||||
@all = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.db_file
|
def self.db_file
|
||||||
|
|
|
@ -5,6 +5,8 @@ class EmojiSetSiteSetting < EnumSiteSetting
|
||||||
# fix the URLs when changing the site setting
|
# fix the URLs when changing the site setting
|
||||||
DiscourseEvent.on(:site_setting_saved) do |site_setting|
|
DiscourseEvent.on(:site_setting_saved) do |site_setting|
|
||||||
if site_setting.name.to_s == "emoji_set" && site_setting.value_changed?
|
if site_setting.name.to_s == "emoji_set" && site_setting.value_changed?
|
||||||
|
Emoji.clear_cache
|
||||||
|
|
||||||
before = "/images/emoji/#{site_setting.value_was}/"
|
before = "/images/emoji/#{site_setting.value_was}/"
|
||||||
after = "/images/emoji/#{site_setting.value}/"
|
after = "/images/emoji/#{site_setting.value}/"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user