Progress on DMs responsiveness

Progress on DMs responsiveness
This commit is contained in:
mgabdev
2020-12-03 22:27:09 -05:00
parent 137a36b810
commit f6a7422704
29 changed files with 682 additions and 186 deletions

View File

@@ -434,7 +434,7 @@ class Account < ApplicationRecord
end
def emojis
@emojis ||= CustomEmoji.from_text(emojifiable_text, domain)
@emojis ||= CustomEmoji.from_text(emojifiable_text)
end
before_create :generate_keys

View File

@@ -25,4 +25,9 @@ class ChatMessage < ApplicationRecord
scope :recent, -> { reorder(created_at: :desc) }
def emojis
return @emojis if defined?(@emojis)
@emojis = CustomEmoji.from_text(text)
end
end

View File

@@ -54,14 +54,14 @@ class CustomEmoji < ApplicationRecord
end
class << self
def from_text(text, domain)
def from_text(text)
return [] if text.blank?
shortcodes = text.scan(SCAN_RE).map(&:first).uniq
return [] if shortcodes.empty?
EntityCache.instance.emoji(shortcodes, domain)
EntityCache.instance.emoji(shortcodes)
end
def search(shortcode)
@@ -72,10 +72,7 @@ class CustomEmoji < ApplicationRecord
private
def remove_entity_cache
Rails.cache.delete(EntityCache.instance.to_key(:emoji, shortcode, domain))
Rails.cache.delete(EntityCache.instance.to_key(:emoji, shortcode,))
end
def downcase_domain
self.domain = domain.downcase unless domain.nil?
end
end

View File

@@ -57,7 +57,7 @@ class Poll < ApplicationRecord
end
def emojis
@emojis ||= CustomEmoji.from_text(options.join(' '), account.domain)
@emojis ||= CustomEmoji.from_text(options.join(' '))
end
class Option < ActiveModelSerializers::Model

View File

@@ -231,7 +231,7 @@ class Status < ApplicationRecord
fields = [spoiler_text, text]
fields += preloadable_poll.options unless preloadable_poll.nil?
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
@emojis = CustomEmoji.from_text(fields.join(' '))
end
def mark_for_mass_destruction!