Skip to content

Commit

Permalink
Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Apr 16, 2024
1 parent 8262f51 commit e94dafb
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 16 deletions.
12 changes: 8 additions & 4 deletions app/javascript/mastodon/components/status_action_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,13 @@ class StatusActionBar extends ImmutablePureComponent {
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancelReblog : messages.reblog), action: this.handleReblogForceModalClick, tag: 'reblog' });

if (publicStatus) {
if (allowQuote) {
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote, tag: 'reblog' });
}

menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
}
}
}

Expand Down Expand Up @@ -439,11 +441,13 @@ class StatusActionBar extends ImmutablePureComponent {
}

if (publicStatus) {
if (allowQuote) {
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
reblogMenu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
}

reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ class ActionBar extends PureComponent {
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancel_reblog : messages.reblog), action: this.handleReblogForceModalClick, tag: 'reblog' });

if (publicStatus) {
if (allowQuote) {
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote, tag: 'reblog' });
}

menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
}
}
}

Expand Down Expand Up @@ -356,11 +358,13 @@ class ActionBar extends PureComponent {
}

if (publicStatus) {
if (allowQuote) {
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
reblogMenu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
}

reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/javascript/mastodon/initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* | 'favourite_menu'
* | 'quote_in_home'
* | 'quote_in_public'
* | 'quote_unavailable_server'
* | 'recent_emojis'
* | 'relationships'
* | 'status_reference_unavailable_server'
* } HideItemsDefinition
*/

Expand Down
8 changes: 8 additions & 0 deletions app/models/concerns/user/has_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ def setting_hide_emoji_reaction_unavailable_server
settings['web.hide_emoji_reaction_unavailable_server']
end

def setting_hide_quote_unavailable_server
settings['web.hide_quote_unavailable_server']
end

def setting_hide_status_reference_unavailable_server
settings['web.hide_status_reference_unavailable_server']
end

def setting_hide_emoji_reaction_count
settings['web.hide_emoji_reaction_count']
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/instance_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class InstanceInfo < ApplicationRecord
sharkey
).freeze

QUOTE_AVAILABLE_SOFTWARES = EMOJI_REACTION_AVAILABLE_SOFTWARES + %w(kmyblue)
QUOTE_AVAILABLE_SOFTWARES = EMOJI_REACTION_AVAILABLE_SOFTWARES

STATUS_REFERENCE_AVAILABLE_SOFTWARES = %w(fedibird kmyblue).freeze
STATUS_REFERENCE_AVAILABLE_SOFTWARES = %w(fedibird).freeze

CIRCLE_AVAILABLE_SOFTWARES = %w(fedibird kmyblue).freeze
CIRCLE_AVAILABLE_SOFTWARES = %w(fedibird).freeze

class << self
def emoji_reaction_available?(domain)
Expand Down
2 changes: 2 additions & 0 deletions app/models/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class KeyError < Error; end
setting :show_relationships, default: true
setting :hide_blocking_quote, default: true
setting :hide_emoji_reaction_unavailable_server, default: false
setting :hide_quote_unavailable_server, default: false
setting :hide_status_reference_unavailable_server, default: false
setting :hide_favourite_menu, default: false
setting :hide_emoji_reaction_count, default: false

Expand Down
2 changes: 2 additions & 0 deletions app/serializers/initial_state_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def meta
object_account_user.setting_hide_recent_emojis ? 'recent_emojis' : nil,
object_account_user.setting_hide_blocking_quote ? 'blocking_quote' : nil,
object_account_user.setting_hide_emoji_reaction_unavailable_server ? 'emoji_reaction_unavailable_server' : nil,
object_account_user.setting_hide_quote_unavailable_server ? 'quote_unavailable_server' : nil,
object_account_user.setting_hide_status_reference_unavailable_server ? 'status_reference_unavailable_server' : nil,
object_account_user.setting_hide_emoji_reaction_count ? 'emoji_reaction_count' : nil,
object_account_user.setting_show_emoji_reaction_on_timeline ? nil : 'emoji_reaction_on_timeline',
object_account_user.setting_show_quote_in_home ? nil : 'quote_in_home',
Expand Down
9 changes: 8 additions & 1 deletion app/views/settings/preferences/appearance/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@
- if Setting.enable_emoji_reaction
= ff.input :'web.enable_emoji_reaction', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_emoji_reaction'), hint: I18n.t('simple_form.hints.defaults.setting_enable_emoji_reaction')
= ff.input :'web.show_emoji_reaction_on_timeline', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_on_timeline')
= ff.input :'web.hide_emoji_reaction_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_emoji_reaction_unavailable_server')
= ff.input :'web.show_emoji_reaction_count', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_count')

%h4= t 'appearance.remote_server_features'

.fields-group
- if Setting.enable_emoji_reaction
= ff.input :'web.hide_emoji_reaction_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_emoji_reaction_unavailable_server')
= ff.input :'web.hide_quote_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_quote_unavailable_server')
= ff.input :'web.hide_status_reference_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_status_reference_unavailable_server')

%h4= t 'appearance.saved_posts'

.fields-group
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ en:
guide_link_text: Everyone can contribute.
media: Media
quotes: Quotes
remote_server_features: Other server features
saved_posts: Saving posts
sensitive_content: Sensitive content
status_action_bar: Post menu
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ ja:
guide_link_text: 誰でも参加することができます。
media: メディア
quotes: 引用
remote_server_features: 他のサーバーの機能
saved_posts: 投稿の記録
sensitive_content: 閲覧注意コンテンツ
status_action_bar: 投稿のメニュー
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ en:
setting_expand_spoilers: Always expand posts marked with content warnings
setting_hide_emoji_reaction_unavailable_server: Hide emoji reaction button from unavailable server
setting_hide_network: Hide your social graph
setting_hide_quote_unavailable_server: Hide quote menu from unavailable server
setting_hide_status_reference_unavailable_server: Hide quiet quote (reference named by Fedibird) menu from unavailable server
setting_lock_follow_from_bot: Request approval about bot follow
setting_public_post_to_unlisted: Convert public post to public unlisted if not using Web app
setting_reduce_motion: Reduce motion in animations
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ ja:
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
setting_hide_emoji_reaction_unavailable_server: 絵文字リアクションに対応していないと思われるサーバーの投稿から絵文字リアクション機能を隠す
setting_hide_network: 繋がりを隠す
setting_hide_quote_unavailable_server: 引用に対応していないと思われるサーバーの投稿からメニューを隠す
setting_hide_status_reference_unavailable_server: ひかえめな引用(Fedibirdの参照)に対応していないと思われるサーバーの投稿からメニューを隠す
setting_lock_follow_from_bot: botからのフォローを承認制にする
setting_show_blocking_quote: ブロックしたユーザーの投稿を引用した投稿を表示する
setting_show_emoji_reaction_count: 投稿につけられた各絵文字の数を表示する
Expand Down
8 changes: 4 additions & 4 deletions spec/models/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
end

describe '.available_features_map' do
subject { described_class.available_features_map(domains)[:emoji_reaction] }
subject { described_class.available_features_map(domains) }

let(:domains) { %w(features_available.com mastodon.com misskey.com) }

Expand All @@ -472,15 +472,15 @@
end

it 'availables if features contains emoji_reaction' do
expect(subject['features_available.com']).to be true
expect(subject['features_available.com'][:emoji_reaction]).to be true
end

it 'unavailables if mastodon server' do
expect(subject['mastodon.com']).to be false
expect(subject['mastodon.com'][:emoji_reaction]).to be false
end

it 'availables if misskey server' do
expect(subject['misskey.com']).to be true
expect(subject['misskey.com'][:emoji_reaction]).to be true
end
end

Expand Down

0 comments on commit e94dafb

Please sign in to comment.