Skip to content

Commit

Permalink
Add: #213 右サイドメニューからお気に入りを削除するオプション
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Nov 9, 2023
1 parent 76f2f2e commit dd2d125
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 36 deletions.
6 changes: 3 additions & 3 deletions app/javascript/mastodon/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Card from '../features/status/components/card';
// to use the progress bar to show download progress
import Bundle from '../features/ui/components/bundle';
import { MediaGallery, Video, Audio } from '../features/ui/util/async-components';
import { displayMedia, enableEmojiReaction, showEmojiReactionOnTimeline, showQuoteInHome, showQuoteInPublic } from '../initial_state';
import { displayMedia, enableEmojiReaction, isShowItem } from '../initial_state';

import { Avatar } from './avatar';
import { AvatarOverlay } from './avatar_overlay';
Expand Down Expand Up @@ -610,7 +610,7 @@ class Status extends ImmutablePureComponent {
if (!this.props.withoutEmojiReactions && status.get('emoji_reactions')) {
const emojiReactions = status.get('emoji_reactions');
if (emojiReactions.size > 0 && enableEmojiReaction) {
emojiReactionsBar = <StatusEmojiReactionsBar emojiReactions={emojiReactions} myReactionOnly={!showEmojiReactionOnTimeline} status={status} onEmojiReact={this.props.onEmojiReact} onUnEmojiReact={this.props.onUnEmojiReact} />;
emojiReactionsBar = <StatusEmojiReactionsBar emojiReactions={emojiReactions} myReactionOnly={!isShowItem('emoji_reaction_on_timeline')} status={status} onEmojiReact={this.props.onEmojiReact} onUnEmojiReact={this.props.onUnEmojiReact} />;
}
}

Expand All @@ -622,7 +622,7 @@ class Status extends ImmutablePureComponent {
const withReference = (!withQuote && status.get('status_references_count') > 0) ? <span className='status__visibility-icon'><Icon id='link' icon={ReferenceIcon} title='Reference' /></span> : null;
const withExpiration = status.get('expires_at') ? <span className='status__visibility-icon'><Icon id='clock-o' icon={TimerIcon} title='Expiration' /></span> : null;

const quote = !muted && status.get('quote_id') && (['public', 'community'].includes(contextType) ? showQuoteInPublic : showQuoteInHome) && <CompactedStatusContainer id={status.get('quote_id')} history={this.props.history} />;
const quote = !muted && status.get('quote_id') && (['public', 'community'].includes(contextType) ? isShowItem('quote_in_public') : isShowItem('quote_in_home')) && <CompactedStatusContainer id={status.get('quote_id')} history={this.props.history} />;

return (
<HotKeys handlers={handlers}>
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/components/status_action_bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { WithRouterPropTypes } from 'mastodon/utils/react_router';

import DropdownMenuContainer from '../containers/dropdown_menu_container';
import EmojiPickerDropdown from '../features/compose/containers/emoji_picker_dropdown_container';
import { enableEmojiReaction , bookmarkCategoryNeeded, simpleTimelineMenu, me, hideEmojiReactionUnavailableServer } from '../initial_state';
import { enableEmojiReaction , bookmarkCategoryNeeded, simpleTimelineMenu, me, isHideItem } from '../initial_state';

import { IconButton } from './icon_button';

Expand Down Expand Up @@ -453,7 +453,7 @@ class StatusActionBar extends ImmutablePureComponent {
<IconButton className='status__action-bar__button' title={intl.formatMessage(messages.hide)} icon='eye' iconComponent={VisibilityIcon} onClick={this.handleHideClick} />
);

const emojiReactionAvailableServer = !hideEmojiReactionUnavailableServer || status.get('emoji_reaction_available_server');
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.get('emoji_reaction_available_server');
const emojiReactionPolicy = account.getIn(['other_settings', 'emoji_reaction_policy']) || 'allow';
const following = emojiReactionPolicy !== 'following_only' || (relationship && relationship.get('following'));
const followed = emojiReactionPolicy !== 'followers_only' || (relationship && relationship.get('followed_by'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

import { hideRecentEmojis } from 'mastodon/initial_state';
import { isHideItem } from 'mastodon/initial_state';

import { useEmoji } from '../../../actions/emojis';
import { changeSetting } from '../../../actions/settings';
Expand Down Expand Up @@ -51,7 +51,7 @@ const getFrequentlyUsedEmojis = createSelector([
deckEmojis = [...new Set(deckEmojis)];

let emojis;
if (!hideRecentEmojis) {
if (!isHideItem('recent_emojis')) {
emojis = emojiCounters
.keySeq()
.filter((ee) => deckEmojis.indexOf(ee) < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { WithRouterPropTypes } from 'mastodon/utils/react_router';

import { IconButton } from '../../../components/icon_button';
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { enableEmojiReaction , bookmarkCategoryNeeded, me, hideEmojiReactionUnavailableServer } from '../../../initial_state';
import { enableEmojiReaction , bookmarkCategoryNeeded, me, isHideItem } from '../../../initial_state';
import EmojiPickerDropdown from '../../compose/containers/emoji_picker_dropdown_container';

const messages = defineMessages({
Expand Down Expand Up @@ -358,7 +358,7 @@ class ActionBar extends PureComponent {
reblogTitle = intl.formatMessage(messages.cannot_reblog);
}

const emojiReactionAvailableServer = !hideEmojiReactionUnavailableServer || status.get('emoji_reaction_available_server');
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.get('emoji_reaction_available_server');
const emojiReactionPolicy = account.getIn(['other_settings', 'emoji_reaction_policy']) || 'allow';
const following = emojiReactionPolicy !== 'following_only' || (relationship && relationship.get('following'));
const followed = emojiReactionPolicy !== 'followers_only' || (relationship && relationship.get('followed_by'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Icon } from 'mastodon/components/icon';
import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder';
import { SearchabilityIcon } from 'mastodon/components/searchability_icon';
import { VisibilityIcon } from 'mastodon/components/visibility_icon';
import { enableEmojiReaction, hideEmojiReactionUnavailableServer } from 'mastodon/initial_state';
import { enableEmojiReaction, isHideItem } from 'mastodon/initial_state';
import { WithRouterPropTypes } from 'mastodon/utils/react_router';

import { Avatar } from '../../../components/avatar';
Expand Down Expand Up @@ -233,7 +233,7 @@ class DetailedStatus extends ImmutablePureComponent {
if (status.get('emoji_reactions')) {
const emojiReactions = status.get('emoji_reactions');
const emojiReactionPolicy = status.getIn(['account', 'other_settings', 'emoji_reaction_policy']) || 'allow';
const emojiReactionAvailableServer = !hideEmojiReactionUnavailableServer || status.get('emoji_reaction_available_server');
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.get('emoji_reaction_available_server');
if (emojiReactions.size > 0 && enableEmojiReaction && emojiReactionAvailableServer && emojiReactionPolicy !== 'block') {
emojiReactionsBar = <StatusEmojiReactionsBar emojiReactions={emojiReactions} status={status} onEmojiReact={this.props.onEmojiReact} onUnEmojiReact={this.props.onUnEmojiReact} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ReactComponent as AntennaIcon } from '@material-symbols/svg-600/outline

import { WordmarkLogo } from 'mastodon/components/logo';
import { NavigationPortal } from 'mastodon/components/navigation_portal';
import { enableDtlMenu, timelinePreview, trendsEnabled, dtlTag, enableLocalTimeline } from 'mastodon/initial_state';
import { enableDtlMenu, timelinePreview, trendsEnabled, dtlTag, enableLocalTimeline, isHideItem } from 'mastodon/initial_state';
import { transientSingleColumn } from 'mastodon/is_mobile';

import ColumnLink from './column_link';
Expand Down Expand Up @@ -151,7 +151,7 @@ class NavigationPanel extends Component {
{signedIn && (
<>
<ColumnLink transparent to='/bookmark_categories' icon='bookmarks' iconComponent={BookmarksIcon} text={intl.formatMessage(messages.bookmarks)} />
<ColumnLink transparent to='/favourites' icon='star' iconComponent={StarIcon} text={intl.formatMessage(messages.favourites)} />
{ !isHideItem('favourite_menu') && <ColumnLink transparent to='/favourites' icon='star' iconComponent={StarIcon} text={intl.formatMessage(messages.favourites)} /> }
<hr />

<ColumnLink transparent href='/settings/preferences' icon='cog' iconComponent={SettingsIcon} text={intl.formatMessage(messages.preferences)} />
Expand Down
38 changes: 26 additions & 12 deletions app/javascript/mastodon/initial_state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// @ts-check


/**
* @typedef { 'blocking_quote'
* | 'emoji_reaction_on_timeline'
* | 'emoji_reaction_unavailable_server'
* | 'favourite_menu'
* | 'quote_in_home'
* | 'quote_in_public'
* | 'recent_emojis'
* } HideItemsDefinition
*/

/**
* @typedef {[code: string, name: string, localName: string]} InitialStateLanguage
*/
Expand All @@ -27,9 +38,7 @@
* @property {boolean} enable_local_timeline
* @property {boolean} enable_dtl_menu
* @property {boolean=} expand_spoilers
* @property {boolean} hide_blocking_quote
* @property {boolean} hide_emoji_reaction_unavailable_server
* @property {boolean} hide_recent_emojis
* @property {HideItemsDefinition[]} hide_items
* @property {boolean} limited_federation_mode
* @property {string} locale
* @property {string | null} mascot
Expand All @@ -42,9 +51,6 @@
* @property {string} repository
* @property {boolean} search_enabled
* @property {boolean} trends_enabled
* @property {boolean} show_emoji_reaction_on_timeline
* @property {boolean} show_quote_in_home
* @property {boolean} show_quote_in_public
* @property {string} simple_timeline_menu
* @property {boolean} single_user_mode
* @property {string} source_url
Expand Down Expand Up @@ -87,6 +93,20 @@ export const hasMultiColumnPath = initialPath === '/'
*/
const getMeta = (prop) => initialState?.meta && initialState.meta[prop];

const hideItems = getMeta('hide_items');

/**
* @param {HideItemsDefinition} key
* @returns {boolean}
*/
export const isHideItem = (key) => (hideItems && hideItems.includes(key)) || false;

/**
* @param {HideItemsDefinition} key
* @returns {boolean}
*/
export const isShowItem = (key) => !isHideItem(key);

export const activityApiEnabled = getMeta('activity_api_enabled');
export const autoPlayGif = getMeta('auto_play_gif');
export const bookmarkCategoryNeeded = getMeta('bookmark_category_needed');
Expand All @@ -105,9 +125,6 @@ export const enableLoginPrivacy = getMeta('enable_login_privacy');
export const enableDtlMenu = getMeta('enable_dtl_menu');
export const expandSpoilers = getMeta('expand_spoilers');
export const forceSingleColumn = !getMeta('advanced_layout');
export const hideBlockingQuote = getMeta('hide_blocking_quote');
export const hideEmojiReactionUnavailableServer = getMeta('hide_emoji_reaction_unavailable_server');
export const hideRecentEmojis = getMeta('hide_recent_emojis');
export const limitedFederationMode = getMeta('limited_federation_mode');
export const mascot = getMeta('mascot');
export const me = getMeta('me');
Expand All @@ -119,9 +136,6 @@ export const registrationsOpen = getMeta('registrations_open');
export const repository = getMeta('repository');
export const searchEnabled = getMeta('search_enabled');
export const trendsEnabled = getMeta('trends_enabled');
export const showEmojiReactionOnTimeline = getMeta('show_emoji_reaction_on_timeline');
export const showQuoteInHome = getMeta('show_quote_in_home');
export const showQuoteInPublic = getMeta('show_quote_in_public');
export const showTrends = getMeta('show_trends');
export const simpleTimelineMenu = getMeta('simple_timeline_menu');
export const singleUserMode = getMeta('single_user_mode');
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createSelector } from 'reselect';

import { toServerSideType } from 'mastodon/utils/filters';

import { me, hideBlockingQuote } from '../initial_state';
import { me, isHideItem } from '../initial_state';

export { makeGetAccount } from "./accounts";

Expand Down Expand Up @@ -40,7 +40,7 @@ export const makeGetStatus = () => {
statusReblog = null;
}

if (hideBlockingQuote && (statusReblog || statusBase).getIn(['quote', 'quote_muted'])) {
if (isHideItem('blocking_quote') && (statusReblog || statusBase).getIn(['quote', 'quote_muted'])) {
return null;
}

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

def setting_hide_favourite_menu
settings['web.hide_favourite_menu']
end

def allows_report_emails?
settings['notification_emails.report']
end
Expand Down
1 change: 1 addition & 0 deletions app/models/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class KeyError < Error; end
setting :show_quote_in_public, default: false
setting :hide_blocking_quote, default: true
setting :hide_emoji_reaction_unavailable_server, default: false
setting :hide_favourite_menu, default: false
end

namespace :notification_emails do
Expand Down
21 changes: 12 additions & 9 deletions app/serializers/initial_state_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ def meta
store[:display_media_expand] = object.current_account.user.setting_display_media_expand
store[:expand_spoilers] = object.current_account.user.setting_expand_spoilers
store[:enable_emoji_reaction] = object.current_account.user.setting_enable_emoji_reaction && Setting.enable_emoji_reaction
store[:show_emoji_reaction_on_timeline] = object.current_account.user.setting_show_emoji_reaction_on_timeline
store[:enable_login_privacy] = object.current_account.user.setting_enable_login_privacy
store[:enable_dtl_menu] = object.current_account.user.setting_enable_dtl_menu
store[:hide_recent_emojis] = object.current_account.user.setting_hide_recent_emojis
store[:reduce_motion] = object.current_account.user.setting_reduce_motion
store[:disable_swiping] = object.current_account.user.setting_disable_swiping
store[:advanced_layout] = object.current_account.user.setting_advanced_layout
Expand All @@ -63,19 +61,24 @@ def meta
store[:show_trends] = Setting.trends && object.current_account.user.setting_trends
store[:bookmark_category_needed] = object.current_account.user.setting_bookmark_category_needed
store[:simple_timeline_menu] = object.current_account.user.setting_simple_timeline_menu
store[:show_quote_in_home] = object.current_account.user.setting_show_quote_in_home
store[:show_quote_in_public] = object.current_account.user.setting_show_quote_in_public
store[:hide_blocking_quote] = object.current_account.user.setting_hide_blocking_quote
store[:hide_emoji_reaction_unavailable_server] = object.current_account.user.setting_hide_emoji_reaction_unavailable_server
store[:hide_items] = [
object.current_account.user.setting_hide_favourite_menu ? 'favourite_menu' : nil,
object.current_account.user.setting_hide_recent_emojis ? 'recent_emojis' : nil,
object.current_account.user.setting_hide_blocking_quote ? 'blocking_quote' : nil,
object.current_account.user.setting_hide_emoji_reaction_unavailable_server ? 'emoji_reaction_unavailable_server' : nil,
object.current_account.user.setting_show_emoji_reaction_on_timeline ? nil : 'emoji_reaction_on_timeline',
object.current_account.user.setting_show_quote_in_home ? nil : 'quote_in_home',
object.current_account.user.setting_show_quote_in_public ? nil : 'quote_in_public',
].compact
else
store[:auto_play_gif] = Setting.auto_play_gif
store[:display_media] = Setting.display_media
store[:reduce_motion] = Setting.reduce_motion
store[:use_blurhash] = Setting.use_blurhash
store[:enable_emoji_reaction] = Setting.enable_emoji_reaction
store[:show_emoji_reaction_on_timeline] = Setting.enable_emoji_reaction
store[:show_quote_in_home] = true
store[:show_quote_in_public] = true
store[:hide_items] = [
Setting.enable_emoji_reaction ? nil : 'emoji_reaction_on_timeline',
].compact
end

store[:disabled_account_id] = object.disabled_account.id.to_s if object.disabled_account
Expand Down
1 change: 1 addition & 0 deletions app/views/settings/preferences/appearance/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

.fields-group
= ff.input :'web.bookmark_category_needed', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_bookmark_category_needed'), hint: I18n.t('simple_form.hints.defaults.setting_bookmark_category_needed')
= ff.input :'web.hide_favourite_menu', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_favourite_menu')

.fields-group
= ff.input :'web.show_quote_in_home', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_quote_in_home'), hint: false
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ en:
setting_expand_spoilers: Always expand posts marked with content warnings
setting_hide_blocking_quote: Hide posts which have a quote written by the user you are blocking
setting_hide_emoji_reaction_unavailable_server: Hide stamp button from unavailable server
setting_hide_favourite_menu: Hide favourite menu
setting_hide_followers_count: Hide followers count
setting_hide_following_count: Hide following count
setting_hide_network: Hide your social graph
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ ja:
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
setting_hide_blocking_quote: ブロックしたユーザーの投稿を引用した投稿を隠す
setting_hide_emoji_reaction_unavailable_server: スタンプに対応していないと思われるサーバーの投稿からスタンプボタンを隠す
setting_hide_favourite_menu: 右サイドメニューから「お気に入り」を隠す
setting_hide_followers_count: フォロワー数を隠す
setting_hide_following_count: フォロー数を隠す
setting_hide_network: 繋がりを隠す
Expand Down

0 comments on commit dd2d125

Please sign in to comment.