diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 591737598..c4399f306 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -81,56 +81,56 @@ @@ -160,7 +160,10 @@ :href="attachment.url" target="_blank" > - +

{{ localDescription }}

diff --git a/src/components/gallery/gallery.vue b/src/components/gallery/gallery.vue index f9cad8a9c..f2e1b5ce5 100644 --- a/src/components/gallery/gallery.vue +++ b/src/components/gallery/gallery.vue @@ -26,8 +26,8 @@ :size="size" :editable="editable" :remove="removeAttachment" - :shiftUp="!(attachmentIndex === 0 && rowIndex === 0) && shiftUpAttachment" - :shiftDn="!(attachmentIndex === row.items.length - 1 && rowIndex === rows.length - 1) && shiftDnAttachment" + :shift-up="!(attachmentIndex === 0 && rowIndex === 0) && shiftUpAttachment" + :shift-dn="!(attachmentIndex === row.items.length - 1 && rowIndex === rows.length - 1) && shiftDnAttachment" :edit="editAttachment" :description="descriptions && descriptions[attachment.id]" :hide-description="size === 'small' || tooManyAttachments && hidingLong" diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index fe07309fc..9d7bbd753 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -117,6 +117,7 @@ const PostStatusForm = { ? this.copyMessageScope : this.$store.state.users.currentUser.default_scope + // const { defaultNSFW: sensitiveByDefault } = this.$store.state.serverSideConfig const { postContentType: contentType, sensitiveByDefault } = this.$store.getters.mergedConfig return { diff --git a/src/components/settings_modal/helpers/boolean_setting.js b/src/components/settings_modal/helpers/boolean_setting.js index 5c52f697c..353e551c9 100644 --- a/src/components/settings_modal/helpers/boolean_setting.js +++ b/src/components/settings_modal/helpers/boolean_setting.js @@ -1,14 +1,17 @@ import { get, set } from 'lodash' import Checkbox from 'src/components/checkbox/checkbox.vue' import ModifiedIndicator from './modified_indicator.vue' +import ServerSideIndicator from './server_side_indicator.vue' export default { components: { Checkbox, - ModifiedIndicator + ModifiedIndicator, + ServerSideIndicator }, props: [ 'path', - 'disabled' + 'disabled', + 'expert' ], computed: { pathDefault () { @@ -26,8 +29,14 @@ export default { defaultState () { return get(this.$parent, this.pathDefault) }, + isServerSide () { + return this.path.startsWith('serverSide_') + }, isChanged () { - return this.state !== this.defaultState + return !this.path.startsWith('serverSide_') && this.state !== this.defaultState + }, + matchesExpertLevel () { + return (this.expert || 0) <= this.$parent.expertLevel } }, methods: { diff --git a/src/components/settings_modal/helpers/boolean_setting.vue b/src/components/settings_modal/helpers/boolean_setting.vue index c3ee6583f..e0d825f20 100644 --- a/src/components/settings_modal/helpers/boolean_setting.vue +++ b/src/components/settings_modal/helpers/boolean_setting.vue @@ -1,5 +1,6 @@ diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js index a15f6bac0..4677d4c19 100644 --- a/src/components/settings_modal/helpers/choice_setting.js +++ b/src/components/settings_modal/helpers/choice_setting.js @@ -1,15 +1,18 @@ import { get, set } from 'lodash' import Select from 'src/components/select/select.vue' import ModifiedIndicator from './modified_indicator.vue' +import ServerSideIndicator from './server_side_indicator.vue' export default { components: { Select, - ModifiedIndicator + ModifiedIndicator, + ServerSideIndicator }, props: [ 'path', 'disabled', - 'options' + 'options', + 'expert' ], computed: { pathDefault () { @@ -27,8 +30,14 @@ export default { defaultState () { return get(this.$parent, this.pathDefault) }, + isServerSide () { + return this.path.startsWith('serverSide_') + }, isChanged () { - return this.state !== this.defaultState + return !this.path.startsWith('serverSide_') && this.state !== this.defaultState + }, + matchesExpertLevel () { + return (this.expert || 0) <= this.$parent.expertLevel } }, methods: { diff --git a/src/components/settings_modal/helpers/choice_setting.vue b/src/components/settings_modal/helpers/choice_setting.vue index fa17661bd..54f5d0a76 100644 --- a/src/components/settings_modal/helpers/choice_setting.vue +++ b/src/components/settings_modal/helpers/choice_setting.vue @@ -1,5 +1,6 @@ diff --git a/src/components/settings_modal/helpers/server_side_indicator.vue b/src/components/settings_modal/helpers/server_side_indicator.vue new file mode 100644 index 000000000..143a86a16 --- /dev/null +++ b/src/components/settings_modal/helpers/server_side_indicator.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/src/components/settings_modal/helpers/shared_computed_object.js b/src/components/settings_modal/helpers/shared_computed_object.js index 2c833c0c0..12431dcaf 100644 --- a/src/components/settings_modal/helpers/shared_computed_object.js +++ b/src/components/settings_modal/helpers/shared_computed_object.js @@ -1,4 +1,5 @@ import { defaultState as configDefaultState } from 'src/modules/config.js' +import { defaultState as serverSideConfigDefaultState } from 'src/modules/serverSideConfig.js' const SharedComputedObject = () => ({ user () { @@ -22,6 +23,14 @@ const SharedComputedObject = () => ({ } }]) .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}), + ...Object.keys(serverSideConfigDefaultState) + .map(key => ['serverSide_' + key, { + get () { return this.$store.state.serverSideConfig[key] }, + set (value) { + this.$store.dispatch('setServerSideOption', { name: key, value }) + } + }]) + .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}), // Special cases (need to transform values or perform actions first) useStreamingApi: { get () { return this.$store.getters.mergedConfig.useStreamingApi }, diff --git a/src/components/settings_modal/settings_modal.js b/src/components/settings_modal/settings_modal.js index 040434833..82ea410e8 100644 --- a/src/components/settings_modal/settings_modal.js +++ b/src/components/settings_modal/settings_modal.js @@ -3,6 +3,7 @@ import PanelLoading from 'src/components/panel_loading/panel_loading.vue' import AsyncComponentError from 'src/components/async_component_error/async_component_error.vue' import getResettableAsyncComponent from 'src/services/resettable_async_component.js' import Popover from '../popover/popover.vue' +import Checkbox from 'src/components/checkbox/checkbox.vue' import { library } from '@fortawesome/fontawesome-svg-core' import { cloneDeep } from 'lodash' import { @@ -51,6 +52,7 @@ const SettingsModal = { components: { Modal, Popover, + Checkbox, SettingsModalContent: getResettableAsyncComponent( () => import('./settings_modal_content.vue'), { @@ -159,6 +161,15 @@ const SettingsModal = { }, modalPeeked () { return this.$store.state.interface.settingsModalState === 'minimized' + }, + expertLevel: { + get () { + return this.$store.state.config.expertLevel > 0 + }, + set (value) { + console.log(value) + this.$store.dispatch('setOption', { name: 'expertLevel', value: value ? 1 : 0 }) + } } } } diff --git a/src/components/settings_modal/settings_modal.scss b/src/components/settings_modal/settings_modal.scss index 90446b363..fb466f2f3 100644 --- a/src/components/settings_modal/settings_modal.scss +++ b/src/components/settings_modal/settings_modal.scss @@ -48,4 +48,11 @@ } } } + + .settings-footer { + display: flex; + >* { + margin-right: 0.5em; + } + } } diff --git a/src/components/settings_modal/settings_modal.vue b/src/components/settings_modal/settings_modal.vue index 583c2ecc1..1805c77fd 100644 --- a/src/components/settings_modal/settings_modal.vue +++ b/src/components/settings_modal/settings_modal.vue @@ -53,7 +53,7 @@
- diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue index 50ee20e09..e60a8a857 100644 --- a/src/components/settings_modal/tabs/filtering_tab.vue +++ b/src/components/settings_modal/tabs/filtering_tab.vue @@ -21,6 +21,7 @@
  • @@ -29,6 +30,7 @@
  • @@ -38,11 +40,15 @@
  • - + {{ $t('settings.hide_post_stats') }}
  • {{ $t('settings.filtering_explanation') }}

    {{ $t('settings.attachments') }}

    -
  • +
  • @@ -84,7 +90,10 @@
  • -
    +

    {{ $t('settings.user_profiles') }}

    • @@ -94,46 +103,6 @@
    -
    -

    {{ $t('settings.notifications') }}

    -
      -
    • - {{ $t('settings.notification_visibility') }} -
        -
      • - - {{ $t('settings.notification_visibility_likes') }} - -
      • -
      • - - {{ $t('settings.notification_visibility_repeats') }} - -
      • -
      • - - {{ $t('settings.notification_visibility_follows') }} - -
      • -
      • - - {{ $t('settings.notification_visibility_mentions') }} - -
      • -
      • - - {{ $t('settings.notification_visibility_moves') }} - -
      • -
      • - - {{ $t('settings.notification_visibility_emoji_reactions') }} - -
      • -
      -
    • -
    -
    diff --git a/src/components/settings_modal/tabs/general_tab.js b/src/components/settings_modal/tabs/general_tab.js index a963d2047..85f22f8ec 100644 --- a/src/components/settings_modal/tabs/general_tab.js +++ b/src/components/settings_modal/tabs/general_tab.js @@ -1,8 +1,10 @@ import BooleanSetting from '../helpers/boolean_setting.vue' import ChoiceSetting from '../helpers/choice_setting.vue' +import ScopeSelector from 'src/components/scope_selector/scope_selector.vue' import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue' import SharedComputedObject from '../helpers/shared_computed_object.js' +import ServerSideIndicator from '../helpers/server_side_indicator.vue' import { library } from '@fortawesome/fontawesome-svg-core' import { faGlobe @@ -47,7 +49,9 @@ const GeneralTab = { components: { BooleanSetting, ChoiceSetting, - InterfaceLanguageSwitcher + InterfaceLanguageSwitcher, + ScopeSelector, + ServerSideIndicator }, computed: { postFormats () { @@ -67,6 +71,11 @@ const GeneralTab = { }, instanceShoutboxPresent () { return this.$store.state.instance.shoutAvailable }, ...SharedComputedObject() + }, + methods: { + changeDefaultScope (value) { + this.$store.dispatch('setServerSideOption', { name: 'defaultScope', value }) + } } } diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue index 6e0bb50d1..d4196c3de 100644 --- a/src/components/settings_modal/tabs/general_tab.vue +++ b/src/components/settings_modal/tabs/general_tab.vue @@ -45,7 +45,10 @@
  • - + {{ $t('settings.useStreamingApi') }}
    @@ -54,22 +57,34 @@
  • - + {{ $t('settings.virtual_scrolling') }}
  • - + {{ $t('settings.always_show_post_button') }}
  • - + {{ $t('settings.autohide_floating_post_button') }}
  • - + {{ $t('settings.hide_shoutbox') }}
  • @@ -84,13 +99,28 @@
  • - + {{ $t('settings.emoji_reactions_on_timeline') }}
  • +
  • + + {{ $t('settings.no_rich_text_description') }} + +
  • {{ $t('settings.attachments') }}

  • - + {{ $t('settings.use_contain_fit') }}
  • @@ -103,6 +133,7 @@
  • {{ $t('settings.preload_images') }} @@ -111,6 +142,7 @@
  • {{ $t('settings.use_one_click_nsfw') }} @@ -118,7 +150,10 @@
  • - + {{ $t('settings.loop_video') }}
      {{ $t('settings.loop_video_silent_only') }} @@ -142,57 +178,14 @@
  • - + {{ $t('settings.play_videos_in_modal') }}
  • -

    {{ $t('settings.fun') }}

    -
  • - - {{ $t('settings.greentext') }} - -
  • -
  • - - {{ $t('settings.show_yous') }} - -
  • -
  • - - {{ $t('settings.conversation_display') }} - -
  • -
      -
    • - - -
    • -
    • - - {{ $t('settings.conversation_other_replies_button') }} - -
    • -
    +

    {{ $t('settings.mention_links') }}

  • -
  • - +
  • + {{ $t('settings.mention_link_show_tooltip') }}
  • -
  • - - {{ $t('settings.use_at_icon') }} - -
  • -
  • - - {{ $t('settings.mention_link_show_avatar') }} - -
  • -
  • - - {{ $t('settings.mention_link_fade_domain') }} - -
  • -
  • - - {{ $t('settings.mention_link_bolden_you') }} - -
  • +
  • + + {{ $t('settings.use_at_icon') }} + +
  • +
  • + + {{ $t('settings.mention_link_show_avatar') }} + +
  • +
  • + + {{ $t('settings.mention_link_fade_domain') }} + +
  • +
  • + + {{ $t('settings.mention_link_bolden_you') }} + +
  • +

    + {{ $t('settings.fun') }} +

    +
  • + + {{ $t('settings.greentext') }} + +
  • +
  • + + {{ $t('settings.show_yous') }} + +
  • -
    +

    {{ $t('settings.composing') }}

    • - + +
    • +
    • + + + {{ $t('settings.sensitive_by_default') }} + +
    • +
    • + {{ $t('settings.scope_copy') }}
    • - + {{ $t('settings.subject_input_always_show') }}
    • @@ -254,6 +303,7 @@ id="subjectLineBehavior" path="subjectLineBehavior" :options="subjectLineOptions" + expert="1" > {{ $t('settings.subject_line_behavior') }} @@ -268,43 +318,39 @@
    • - + {{ $t('settings.minimal_scopes_mode') }}
    • - - {{ $t('settings.sensitive_by_default') }} - -
    • -
    • - + {{ $t('settings.always_show_post_button') }}
    • - + {{ $t('settings.autohide_floating_post_button') }}
    • - + {{ $t('settings.pad_emoji') }}
    - -
    -

    {{ $t('settings.notifications') }}

    -
      -
    • - - {{ $t('settings.enable_web_push_notifications') }} - -
    • -
    -
    diff --git a/src/components/settings_modal/tabs/notifications_tab.js b/src/components/settings_modal/tabs/notifications_tab.js index 3e44c95df..3c6ab87fe 100644 --- a/src/components/settings_modal/tabs/notifications_tab.js +++ b/src/components/settings_modal/tabs/notifications_tab.js @@ -1,4 +1,5 @@ -import Checkbox from 'src/components/checkbox/checkbox.vue' +import BooleanSetting from '../helpers/boolean_setting.vue' +import SharedComputedObject from '../helpers/shared_computed_object.js' const NotificationsTab = { data () { @@ -9,12 +10,13 @@ const NotificationsTab = { } }, components: { - Checkbox + BooleanSetting }, computed: { user () { return this.$store.state.users.currentUser - } + }, + ...SharedComputedObject() }, methods: { updateNotificationSettings () { diff --git a/src/components/settings_modal/tabs/notifications_tab.vue b/src/components/settings_modal/tabs/notifications_tab.vue index 7e0568ead..86be60958 100644 --- a/src/components/settings_modal/tabs/notifications_tab.vue +++ b/src/components/settings_modal/tabs/notifications_tab.vue @@ -2,30 +2,77 @@

    {{ $t('settings.notification_setting_filters') }}

    -

    - - {{ $t('settings.notification_setting_block_from_strangers') }} - -

    +
      +
    • + + {{ $t('settings.notification_setting_block_from_strangers') }} + +
    • +
    • + {{ $t('settings.notification_visibility') }} +
        +
      • + + {{ $t('settings.notification_visibility_likes') }} + +
      • +
      • + + {{ $t('settings.notification_visibility_repeats') }} + +
      • +
      • + + {{ $t('settings.notification_visibility_follows') }} + +
      • +
      • + + {{ $t('settings.notification_visibility_mentions') }} + +
      • +
      • + + {{ $t('settings.notification_visibility_moves') }} + +
      • +
      • + + {{ $t('settings.notification_visibility_emoji_reactions') }} + +
      • +
      +
    • +
    -
    +

    {{ $t('settings.notification_setting_privacy') }}

    -

    - - {{ $t('settings.notification_setting_hide_notification_contents') }} - -

    +
      +
    • + + {{ $t('settings.enable_web_push_notifications') }} + +
    • +
    • + + {{ $t('settings.notification_setting_hide_notification_contents') }} + +
    • +

    {{ $t('settings.notification_mutes') }}

    {{ $t('settings.notification_blocks') }}

    -
    diff --git a/src/components/settings_modal/tabs/profile_tab.js b/src/components/settings_modal/tabs/profile_tab.js index 64079fcdd..bee8a7bb4 100644 --- a/src/components/settings_modal/tabs/profile_tab.js +++ b/src/components/settings_modal/tabs/profile_tab.js @@ -8,6 +8,9 @@ import EmojiInput from 'src/components/emoji_input/emoji_input.vue' import suggestor from 'src/components/emoji_input/suggestor.js' import Autosuggest from 'src/components/autosuggest/autosuggest.vue' import Checkbox from 'src/components/checkbox/checkbox.vue' +import BooleanSetting from '../helpers/boolean_setting.vue' +import SharedComputedObject from '../helpers/shared_computed_object.js' + import { library } from '@fortawesome/fontawesome-svg-core' import { faTimes, @@ -27,18 +30,10 @@ const ProfileTab = { newName: this.$store.state.users.currentUser.name_unescaped, newBio: unescape(this.$store.state.users.currentUser.description), newLocked: this.$store.state.users.currentUser.locked, - newNoRichText: this.$store.state.users.currentUser.no_rich_text, - newDefaultScope: this.$store.state.users.currentUser.default_scope, newFields: this.$store.state.users.currentUser.fields.map(field => ({ name: field.name, value: field.value })), - hideFollows: this.$store.state.users.currentUser.hide_follows, - hideFollowers: this.$store.state.users.currentUser.hide_followers, - hideFollowsCount: this.$store.state.users.currentUser.hide_follows_count, - hideFollowersCount: this.$store.state.users.currentUser.hide_followers_count, showRole: this.$store.state.users.currentUser.show_role, role: this.$store.state.users.currentUser.role, - discoverable: this.$store.state.users.currentUser.discoverable, bot: this.$store.state.users.currentUser.bot, - allowFollowingMove: this.$store.state.users.currentUser.allow_following_move, pickAvatarBtnVisible: true, bannerUploading: false, backgroundUploading: false, @@ -54,12 +49,14 @@ const ProfileTab = { EmojiInput, Autosuggest, ProgressButton, - Checkbox + Checkbox, + BooleanSetting }, computed: { user () { return this.$store.state.users.currentUser }, + ...SharedComputedObject(), emojiUserSuggestor () { return suggestor({ emoji: [ @@ -123,15 +120,7 @@ const ProfileTab = { /* eslint-disable camelcase */ display_name: this.newName, fields_attributes: this.newFields.filter(el => el != null), - default_scope: this.newDefaultScope, - no_rich_text: this.newNoRichText, - hide_follows: this.hideFollows, - hide_followers: this.hideFollowers, - discoverable: this.discoverable, bot: this.bot, - allow_following_move: this.allowFollowingMove, - hide_follows_count: this.hideFollowsCount, - hide_followers_count: this.hideFollowersCount, show_role: this.showRole /* eslint-enable camelcase */ } }).then((user) => { diff --git a/src/components/settings_modal/tabs/profile_tab.vue b/src/components/settings_modal/tabs/profile_tab.vue index bb3c301d5..e00f6e5b9 100644 --- a/src/components/settings_modal/tabs/profile_tab.vue +++ b/src/components/settings_modal/tabs/profile_tab.vue @@ -25,61 +25,6 @@ class="bio resize-height" /> -

    - - {{ $t('settings.lock_account_description') }} - -

    -
    - -
    - -
    -
    -

    - - {{ $t('settings.no_rich_text_description') }} - -

    -

    - - {{ $t('settings.hide_follows_description') }} - -

    -

    - - {{ $t('settings.hide_follows_count_description') }} - -

    -

    - - {{ $t('settings.hide_followers_description') }} - -

    -

    - - {{ $t('settings.hide_followers_count_description') }} - -

    -

    - - {{ $t('settings.allow_following_move') }} - -

    -

    - - {{ $t('settings.discoverable') }} - -

    {{ $t('settings.profile_fields.label') }}

    +
    +

    {{ $t('settings.account_privacy') }}

    +
      +
    • + + {{ $t('settings.lock_account_description') }} + +
    • +
    • + + {{ $t('settings.discoverable') }} + +
    • +
    • + + {{ $t('settings.allow_following_move') }} + +
    • +
    • + + {{ $t('settings.hide_favorites_description') }} + +
    • +
    • + + {{ $t('settings.hide_followers_description') }} + +
        +
      • + + {{ $t('settings.hide_followers_count_description') }} + +
      • +
      +
    • +
    • + + {{ $t('settings.hide_follows_description') }} + +
        +
      • + + {{ $t('settings.hide_follows_count_description') }} + +
      • +
      +
    • +
    +
    diff --git a/src/i18n/en.json b/src/i18n/en.json index f83b8f18e..da5e662db 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -259,13 +259,14 @@ }, "settings": { "app_name": "App name", + "expert_mode": "Show advanced", "save": "Save changes", "security": "Security", "setting_changed": "Setting is different from default", + "setting_server_side": "This setting is tied to your profile and affects all sessions and clients", "enter_current_password_to_confirm": "Enter your current password to confirm your identity", "post_look_feel": "Posts Look & Feel", - "mentions_new_style": "Fancier mention links", - "mentions_new_place": "Put mentions on a separate line", + "mention_links": "Mention links", "mfa": { "otp": "OTP", "setup_otp": "Setup OTP", @@ -402,6 +403,7 @@ "name": "Label", "value": "Content" }, + "account_privacy": "Privacy", "use_contain_fit": "Don't crop the attachment in thumbnails", "name": "Name", "name_bio": "Name & bio", @@ -419,6 +421,7 @@ "no_rich_text_description": "Strip rich text formatting from all posts", "no_blocks": "No blocks", "no_mutes": "No mutes", + "hide_favorites_description": "Don't show list of my favorites (people still get notified)", "hide_follows_description": "Don't show who I'm following", "hide_followers_description": "Don't show who's following me", "hide_follows_count_description": "Don't show follow count", @@ -432,7 +435,7 @@ "valid_until": "Valid until", "revoke_token": "Revoke", "panelRadius": "Panels", - "pause_on_unfocused": "Pause streaming when tab is not focused", + "pause_on_unfocused": "Pause when tab is not focused", "presets": "Presets", "profile_background": "Profile background", "profile_banner": "Profile banner", @@ -467,18 +470,10 @@ "subject_line_email": "Like email: \"re: subject\"", "subject_line_mastodon": "Like mastodon: copy as is", "subject_line_noop": "Do not copy", - "conversation_display": "Conversation display style", - "conversation_display_tree": "Tree-style", - "conversation_display_simple_tree": "Simplified tree-style", - "conversation_display_linear": "Linear-style", - "conversation_other_replies_button": "Show the \"other replies\" button", - "conversation_other_replies_button_below": "Below statuses", - "conversation_other_replies_button_inside": "Inside statuses", - "max_depth_in_thread": "Maximum number of levels in thread to display by default", "post_status_content_type": "Post status content type", "sensitive_by_default": "Mark posts as sensitive by default", "stop_gifs": "Pause animated images until you hover on them", - "streaming": "Enable automatic streaming of new posts when scrolled to the top", + "streaming": "Automatically show new posts when scrolled to the top", "user_mutes": "Users", "useStreamingApi": "Receive posts and notifications real-time", "useStreamingApiWarning": "(Not recommended, experimental, known to skip posts)", @@ -731,7 +726,6 @@ "reply_to": "Reply to", "mentions": "Mentions", "replies_list": "Replies:", - "replies_list_with_others": "Replies (+{numReplies} other): | Replies (+{numReplies} others):", "mute_conversation": "Mute conversation", "unmute_conversation": "Unmute conversation", "status_unavailable": "Status unavailable", @@ -758,18 +752,7 @@ "attachment_stop_flash": "Stop Flash player", "move_up": "Shift attachment left", "move_down": "Shift attachment right", - "open_gallery": "Open gallery", - "thread_hide": "Hide this thread", - "thread_show": "Show this thread", - "thread_show_full": "Show everything under this thread ({numStatus} status in total, max depth {depth}) | Show everything under this thread ({numStatus} statuses in total, max depth {depth})", - "thread_show_full_with_icon": "{icon} {text}", - "thread_follow": "See the remaining part of this thread ({numStatus} status in total) | See the remaining part of this thread ({numStatus} statuses in total)", - "thread_follow_with_icon": "{icon} {text}", - "ancestor_follow": "See {numReplies} other reply under this status | See {numReplies} other replies under this status", - "ancestor_follow_with_icon": "{icon} {text}", - "show_all_conversation_with_icon": "{icon} {text}", - "show_all_conversation": "Show full conversation ({numStatus} other status) | Show full conversation ({numStatus} other statuses)", - "show_only_conversation_under_this": "Only show replies to this status" + "open_gallery": "Open gallery" }, "user_card": { "approve": "Approve", diff --git a/src/main.js b/src/main.js index 034935256..bdf8368b5 100644 --- a/src/main.js +++ b/src/main.js @@ -11,6 +11,7 @@ import statusesModule from './modules/statuses.js' import usersModule from './modules/users.js' import apiModule from './modules/api.js' import configModule from './modules/config.js' +import serverSideConfigModule from './modules/serverSideConfig.js' import shoutModule from './modules/shout.js' import oauthModule from './modules/oauth.js' import authFlowModule from './modules/auth_flow.js' @@ -90,6 +91,7 @@ const persistedStateOptions = { users: usersModule, api: apiModule, config: configModule, + serverSideConfig: serverSideConfigModule, shout: shoutModule, oauth: oauthModule, authFlow: authFlowModule, diff --git a/src/modules/config.js b/src/modules/config.js index a111abca4..c49010cb1 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -18,6 +18,7 @@ export const multiChoiceProperties = [ ] export const defaultState = { + expertLevel: 0, // used to track which settings to show and hide colors: {}, theme: undefined, customTheme: undefined, @@ -43,7 +44,7 @@ export const defaultState = { alwaysShowNewPostButton: false, autohideFloatingPostButton: false, pauseOnUnfocused: true, - stopGifs: false, + stopGifs: true, replyVisibility: 'all', notificationVisibility: { follows: true, @@ -71,7 +72,7 @@ export const defaultState = { hideFilteredStatuses: undefined, // instance default playVideosInModal: false, useOneClickNsfw: false, - useContainFit: false, + useContainFit: true, greentext: undefined, // instance default useAtIcon: undefined, // instance default mentionLinkDisplay: undefined, // instance default diff --git a/src/modules/serverSideConfig.js b/src/modules/serverSideConfig.js new file mode 100644 index 000000000..4f0cd9657 --- /dev/null +++ b/src/modules/serverSideConfig.js @@ -0,0 +1,119 @@ +import { get, set } from 'lodash' + +export const settingsMapGet = { + 'defaultScope': 'source.privacy', + 'defaultNSFW': 'source.sensitive', // BROKEN: pleroma/pleroma#2837 + 'stripRichContent': 'source.pleroma.no_rich_text', + // Privacy + 'locked': 'locked', + 'acceptChatMessages': 'pleroma.accepts_chat_messages', + 'allowFollowingMove': 'pleroma.allow_following_move', + 'discoverable': 'source.discoverable', + 'hideFavorites': 'pleroma.hide_favorites', + 'hideFollowers': 'pleroma.hide_followers', + 'hideFollows': 'pleroma.hide_follows', + 'hideFollowersCount': 'pleroma.hide_followers_count', + 'hideFollowsCount': 'pleroma.hide_follows_count', + // NotificationSettingsAPIs + 'webPushHideContents': 'pleroma.notification_settings.hide_notification_contents', + 'blockNotificationsFromStrangers': 'pleroma.notification_settings.block_from_strangers' +} + +export const settingsMapSet = { + 'defaultScope': 'source.privacy', + 'defaultNSFW': 'source.sensitive', + 'stripRichContent': 'no_rich_text', + // Privacy + 'locked': 'locked', + 'acceptChatMessages': 'accepts_chat_messages', + 'allowFollowingMove': 'allow_following_move', + 'discoverable': 'source.discoverable', + 'hideFavorites': 'hide_favorites', + 'hideFollowers': 'hide_followers', + 'hideFollows': 'hide_follows', + 'hideFollowersCount': 'hide_followers_count', + 'hideFollowsCount': 'hide_follows_count', + // NotificationSettingsAPIs + 'webPushHideContents': 'hide_notification_contents', + 'blockNotificationsFromStrangers': 'block_from_strangers' +} + +export const customAPIs = { + __defaultApi: 'updateProfile', + 'webPushHideContents': 'updateNotificationSettings', + 'blockNotificationsFromStrangers': 'updateNotificationSettings' +} + +export const defaultState = Object.fromEntries(Object.keys(settingsMapGet).map(key => [key, null])) + +const serverSideConfig = { + state: { ...defaultState }, + mutations: { + confirmServerSideOption (state, { name, value }) { + set(state, name, value) + }, + wipeServerSideOption (state, { name }) { + set(state, name, null) + }, + wipeAllServerSideOptions (state) { + Object.keys(settingsMapGet).forEach(key => { + set(state, key, null) + }) + }, + // Set the settings based on their path location + setCurrentUser (state, user) { + Object.entries(settingsMapGet).forEach(([name, path]) => { + set(state, name, get(user._original, path)) + }) + } + }, + actions: { + setServerSideOption ({ rootState, state, commit, dispatch }, { name, value }) { + const oldValue = get(state, name) + const params = {} + const path = settingsMapSet[name] + if (!path) throw new Error('Invalid server-side setting') + commit('wipeServerSideOption', { name }) + const customAPIName = customAPIs[name] || customAPIs.__defaultApi + const api = rootState.api.backendInteractor[customAPIName] + let prefix = '' + switch (customAPIName) { + case 'updateNotificationSettings': + prefix = 'settings.' + break + default: + prefix = 'params.' + break + } + + set(params, prefix + path, value) + api(params) + .then((result) => { + switch (customAPIName) { + case 'updateNotificationSettings': + console.log(result) + if (result.status === 'success') { + commit('confirmServerSideOption', { name, value }) + } else { + commit('confirmServerSideOption', { name, value: oldValue }) + } + break + default: + commit('addNewUsers', [result]) + commit('setCurrentUser', result) + break + } + console.log(state) + }) + .catch((e) => { + console.warn('Error setting server-side option:', e) + commit('confirmServerSideOption', { name, value: oldValue }) + }) + }, + logout ({ commit }) { + commit('wipeAllServerSideOptions') + } + } +} + +export default serverSideConfig diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 7025d8032..f219c161f 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -44,6 +44,7 @@ export const parseUser = (data) => { const mastoShort = masto && !data.hasOwnProperty('avatar') output.id = String(data.id) + output._original = data // used for server-side settings if (masto) { output.screen_name = data.acct