[WIP] remote-only emojis

This commit is contained in:
Matthew Jorgensen 2022-06-13 15:42:38 -05:00 committed by Matty Jorgensen
parent 5aebdc9bcb
commit ed9bbd1fc3
No known key found for this signature in database
3 changed files with 11 additions and 3 deletions

View File

@ -53,6 +53,7 @@ class CustomEmoji < ApplicationRecord
scope :local, -> { where(domain: nil) }
scope :remote, -> { where.not(domain: nil) }
scope :enabled, -> { where(disabled: false) }
scope :remote_only, -> { where.not(domain: nil).where(category_id: nil) }
scope :alphabetic, -> { order(domain: :asc, shortcode: :asc) }
scope :by_domain_and_subdomains, ->(domain) { where(domain: domain).or(where(arel_table[:domain].matches("%.#{domain}"))) }
scope :listed, -> { local.enabled.where(visible_in_picker: true) }

View File

@ -4,6 +4,7 @@ class CustomEmojiFilter
KEYS = %i(
local
remote
remote_only
by_domain
shortcode
).freeze
@ -21,6 +22,8 @@ class CustomEmojiFilter
next if key.to_s == 'page'
scope.merge!(scope_for(key, value)) if value.present?
scope = CustomEmoji.remote_only if key.to_s == 'remote_only'
end
scope
@ -34,6 +37,8 @@ class CustomEmojiFilter
CustomEmoji.local.left_joins(:category).reorder(CustomEmojiCategory.arel_table[:name].asc.nulls_first).order(shortcode: :asc)
when 'remote'
CustomEmoji.remote
when 'remote_only'
CustomEmoji.remote_only
when 'by_domain'
CustomEmoji.where(domain: value.strip.downcase)
when 'shortcode'

View File

@ -9,17 +9,19 @@
.filter-subset
%strong= t('admin.accounts.location.title')
%ul
%li= filter_link_to t('admin.accounts.location.all'), local: nil, remote: nil
%li= filter_link_to t('admin.accounts.location.all'), local: nil, remote: nil, remote_only: nil
%li
- if selected? local: '1', remote: nil
= filter_link_to t('admin.accounts.location.local'), { local: nil, remote: nil }, { local: '1', remote: nil }
- else
= filter_link_to t('admin.accounts.location.local'), local: '1', remote: nil
= filter_link_to t('admin.accounts.location.local'), local: '1', remote: nil, remote_only: nil
%li
- if selected? remote: '1', local: nil
= filter_link_to t('admin.accounts.location.remote'), { remote: nil, local: nil }, { remote: '1', local: nil }
- else
= filter_link_to t('admin.accounts.location.remote'), remote: '1', local: nil
= filter_link_to t('admin.accounts.location.remote'), remote: '1', local: nil, remote_only: nil
%li
= filter_link_to t('admin.accounts.location.remote_only'), remote_only: '1', remote: nil, local: nil
= form_with url: admin_custom_emojis_url, method: :get, class: :simple_form do |form|
.fields-group