From d7688fafd367f8e32ce94278b3ac3f91ba89ee6b Mon Sep 17 00:00:00 2001 From: emma Date: Thu, 8 Dec 2022 16:48:17 +0000 Subject: [PATCH] format everything --- .prettierrc | 6 + src/App.js | 83 ++- src/App.vue | 2 +- src/boot/after_store.js | 265 +++++--- src/boot/routes.js | 146 ++++- src/components/about/about.js | 12 +- src/components/about/about.vue | 5 +- .../account_actions/account_actions.js | 49 +- .../account_actions/account_actions.vue | 10 +- src/components/announcement/announcement.js | 65 +- src/components/announcement/announcement.vue | 9 +- .../announcement_editor.vue | 16 +- .../announcements_page/announcements_page.js | 17 +- .../announcements_page/announcements_page.vue | 13 +- .../async_component_error.vue | 6 +- src/components/attachment/attachment.js | 75 +-- src/components/attachment/attachment.vue | 34 +- src/components/auth_form/auth_form.js | 12 +- src/components/autosuggest/autosuggest.js | 22 +- src/components/autosuggest/autosuggest.vue | 2 +- src/components/avatar_list/avatar_list.js | 10 +- src/components/avatar_list/avatar_list.vue | 2 +- .../awaiting_email_confirmation.js | 3 +- .../basic_user_card/basic_user_card.js | 16 +- src/components/block_card/block_card.js | 12 +- .../bookmark_timeline/bookmark_timeline.js | 4 +- .../bubble_timeline/bubble_timeline.js | 9 +- .../chat_message_date/chat_message_date.vue | 7 +- src/components/checkbox/checkbox.vue | 17 +- src/components/color_input/color_input.vue | 23 +- src/components/confirm_modal/confirm_modal.js | 7 +- .../confirm_modal/confirm_modal.vue | 4 +- .../contrast_ratio/contrast_ratio.vue | 34 +- .../conversation-page/conversation-page.js | 2 +- src/components/conversation/conversation.js | 351 ++++++----- src/components/conversation/conversation.vue | 99 +-- src/components/desktop_nav/desktop_nav.js | 96 +-- src/components/desktop_nav/desktop_nav.vue | 14 +- src/components/dialog_modal/dialog_modal.vue | 9 +- src/components/dm_timeline/dm_timeline.js | 2 +- .../domain_mute_card/domain_mute_card.js | 8 +- .../domain_mute_card/domain_mute_card.vue | 4 +- .../edit_status_modal/edit_status_modal.js | 25 +- .../edit_status_modal/edit_status_modal.vue | 6 +- src/components/emoji_input/emoji_input.js | 160 ++--- src/components/emoji_input/emoji_input.vue | 16 +- src/components/emoji_input/suggestor.js | 99 ++- src/components/emoji_picker/emoji_picker.js | 90 +-- src/components/emoji_picker/emoji_picker.vue | 16 +- .../emoji_reactions/emoji_reactions.js | 30 +- .../emoji_reactions/emoji_reactions.vue | 16 +- src/components/exporter/exporter.js | 36 +- src/components/extra_buttons/extra_buttons.js | 209 ++++--- .../extra_buttons/extra_buttons.vue | 34 +- .../favorite_button/favorite_button.js | 19 +- .../favorite_button/favorite_button.vue | 2 +- .../features_panel/features_panel.js | 18 +- .../features_panel/features_panel.vue | 13 +- src/components/flash/flash.js | 28 +- src/components/follow_button/follow_button.js | 38 +- .../follow_button/follow_button.vue | 4 +- src/components/follow_card/follow_card.js | 11 +- .../follow_request_card.js | 35 +- .../follow_requests/follow_requests.js | 2 +- src/components/font_control/font_control.js | 34 +- src/components/font_control/font_control.vue | 13 +- .../friends_timeline/friends_timeline.js | 4 +- src/components/gallery/gallery.js | 95 +-- src/components/gallery/gallery.vue | 29 +- .../global_notice_list/global_notice_list.js | 12 +- src/components/hashtag_link/hashtag_link.js | 4 +- src/components/hashtag_link/hashtag_link.vue | 8 +- src/components/image_cropper/image_cropper.js | 41 +- .../image_cropper/image_cropper.vue | 4 +- src/components/importer/importer.js | 30 +- src/components/importer/importer.vue | 10 +- .../instance_specific_panel.js | 2 +- .../instance_specific_panel.vue | 2 +- src/components/interactions/interactions.js | 7 +- src/components/interactions/interactions.vue | 2 +- .../interface_language_switcher.vue | 8 +- src/components/link-preview/link-preview.js | 22 +- src/components/link-preview/link-preview.vue | 9 +- src/components/list/list.vue | 2 +- src/components/list_card/list_card.js | 12 +- src/components/list_edit/list_edit.js | 67 +-- src/components/list_edit/list_edit.vue | 2 +- src/components/list_new/list_new.js | 50 +- src/components/list_new/list_new.vue | 6 +- src/components/list_timeline/list_timeline.js | 15 +- .../list_user_search/list_user_search.js | 29 +- .../list_user_search/list_user_search.vue | 3 +- src/components/lists/lists.js | 10 +- src/components/lists/lists.vue | 2 +- .../local_bubble_panel/local_bubble_panel.js | 2 +- .../local_bubble_panel/local_bubble_panel.vue | 4 +- src/components/login_form/login_form.js | 88 +-- src/components/login_form/login_form.vue | 14 +- src/components/media_modal/media_modal.js | 66 +- src/components/media_modal/media_modal.vue | 27 +- src/components/media_upload/media_upload.js | 48 +- src/components/media_upload/media_upload.vue | 6 +- src/components/mention_link/mention_link.js | 76 ++- src/components/mention_link/mention_link.vue | 39 +- src/components/mentions/mentions.js | 2 +- src/components/mentions_line/mentions_line.js | 8 +- .../mentions_line/mentions_line.vue | 10 +- src/components/mfa_form/recovery_form.js | 14 +- src/components/mfa_form/recovery_form.vue | 6 +- src/components/mfa_form/totp_form.js | 14 +- src/components/mfa_form/totp_form.vue | 4 +- src/components/mobile_nav/mobile_nav.js | 56 +- src/components/mobile_nav/mobile_nav.vue | 11 +- .../mobile_post_status_button.js | 66 +- .../mobile_post_status_button.vue | 3 +- src/components/mod_modal/mod_modal.js | 33 +- src/components/mod_modal/mod_modal_content.js | 28 +- .../mod_modal/tabs/reports_tab/report_card.js | 105 ++-- .../tabs/reports_tab/report_card.vue | 61 +- .../mod_modal/tabs/reports_tab/report_note.js | 21 +- .../tabs/reports_tab/report_note.vue | 2 +- .../mod_modal/tabs/reports_tab/reports_tab.js | 6 +- .../tabs/reports_tab/reports_tab.vue | 8 +- src/components/modal/modal.vue | 4 +- .../moderation_tools/moderation_tools.js | 103 ++-- .../moderation_tools/moderation_tools.vue | 49 +- .../mrf_transparency_panel.js | 106 ++-- .../mrf_transparency_panel.vue | 78 +-- src/components/mute_card/mute_card.js | 12 +- src/components/nav_panel/nav_panel.js | 14 +- src/components/nav_panel/nav_panel.vue | 17 +- src/components/notification/notification.js | 76 ++- src/components/notification/notification.vue | 26 +- .../notifications/notification_filters.vue | 14 +- src/components/notifications/notifications.js | 68 ++- .../notifications/notifications.vue | 11 +- .../oauth_callback/oauth_callback.js | 24 +- .../opacity_input/opacity_input.vue | 12 +- .../panel_loading/panel_loading.vue | 4 +- .../password_reset/password_reset.js | 50 +- .../password_reset/password_reset.vue | 11 +- src/components/pinch_zoom/pinch_zoom.js | 6 +- src/components/poll/poll.js | 76 ++- src/components/poll/poll.vue | 18 +- src/components/poll/poll_form.js | 76 +-- src/components/poll/poll_form.vue | 6 +- src/components/popover/popover.js | 101 ++-- src/components/popover/popover.vue | 12 +- .../post_status_form/post_status_form.js | 346 ++++++----- .../post_status_form/post_status_form.vue | 76 ++- .../post_status_modal/post_status_modal.js | 26 +- .../progress_button/progress_button.vue | 11 +- .../public_and_external_timeline.js | 12 +- .../public_timeline/public_timeline.js | 9 +- src/components/quote_button/quote_button.js | 2 +- src/components/quote_button/quote_button.vue | 3 +- src/components/quote_card/quote_card.js | 10 +- src/components/quote_card/quote_card.vue | 4 +- .../quote_card_content/quote_card_content.vue | 4 +- src/components/range_input/range_input.vue | 19 +- src/components/react_button/react_button.js | 12 +- src/components/react_button/react_button.vue | 11 +- src/components/registration/registration.js | 33 +- src/components/registration/registration.vue | 79 ++- .../registration_request_sent.js | 3 +- src/components/remote_follow/remote_follow.js | 4 +- .../remote_follow/remote_follow.vue | 4 +- .../remote_user_resolver.js | 10 +- .../remote_user_resolver.vue | 7 +- .../remove_follower_button.js | 14 +- src/components/reply_button/reply_button.js | 8 +- src/components/reply_button/reply_button.vue | 3 +- .../retweet_button/retweet_button.js | 22 +- .../retweet_button/retweet_button.vue | 8 +- .../scope_selector/scope_selector.js | 44 +- .../scope_selector/scope_selector.vue | 1 - src/components/search/search.js | 48 +- src/components/search/search.vue | 19 +- src/components/search_bar/search_bar.js | 16 +- src/components/search_bar/search_bar.vue | 3 +- src/components/select/select.js | 15 +- src/components/select/select.vue | 5 +- .../selectable_list/selectable_list.js | 22 +- .../selectable_list/selectable_list.vue | 6 +- .../settings_modal/helpers/boolean_setting.js | 24 +- .../helpers/boolean_setting.vue | 5 +- .../settings_modal/helpers/choice_setting.js | 26 +- .../settings_modal/helpers/choice_setting.vue | 10 +- .../settings_modal/helpers/integer_setting.js | 12 +- .../helpers/integer_setting.vue | 2 +- .../helpers/modified_indicator.vue | 12 +- .../helpers/server_side_indicator.vue | 12 +- .../helpers/shared_computed_object.js | 63 +- .../settings_modal/settings_modal.js | 65 +- .../settings_modal/settings_modal.vue | 35 +- .../settings_modal/settings_modal_content.js | 18 +- .../tabs/data_import_export_tab.js | 96 +-- .../tabs/data_import_export_tab.vue | 8 +- .../settings_modal/tabs/filtering_tab.js | 13 +- .../settings_modal/tabs/filtering_tab.vue | 2 +- .../settings_modal/tabs/general_tab.js | 157 +++-- .../settings_modal/tabs/general_tab.vue | 76 ++- .../tabs/mutes_and_blocks_tab.js | 77 +-- .../tabs/mutes_and_blocks_tab.vue | 52 +- .../settings_modal/tabs/notifications_tab.js | 14 +- .../settings_modal/tabs/notifications_tab.vue | 4 +- .../settings_modal/tabs/profile_tab.js | 154 +++-- .../settings_modal/tabs/profile_tab.vue | 32 +- .../tabs/security_tab/confirm.js | 8 +- .../tabs/security_tab/confirm.vue | 3 +- .../settings_modal/tabs/security_tab/mfa.js | 98 +-- .../settings_modal/tabs/security_tab/mfa.vue | 18 +- .../tabs/security_tab/mfa_backup_codes.js | 12 +- .../tabs/security_tab/mfa_totp.js | 22 +- .../tabs/security_tab/mfa_totp.vue | 2 +- .../tabs/security_tab/security_tab.js | 59 +- .../tabs/security_tab/security_tab.vue | 38 +- .../settings_modal/tabs/theme_tab/preview.vue | 27 +- .../tabs/theme_tab/theme_tab.js | 415 +++++++------ .../tabs/theme_tab/theme_tab.vue | 11 +- .../settings_modal/tabs/version_tab.js | 6 +- .../settings_modal/tabs/version_tab.vue | 6 +- .../shadow_control/shadow_control.js | 58 +- .../shadow_control/shadow_control.vue | 49 +- src/components/side_drawer/side_drawer.js | 43 +- src/components/side_drawer/side_drawer.vue | 75 ++- src/components/staff_panel/staff_panel.js | 20 +- src/components/staff_panel/staff_panel.vue | 6 +- src/components/status/status.js | 365 +++++++----- src/components/status/status.vue | 80 ++- src/components/status_body/status_body.js | 84 +-- src/components/status_body/status_body.vue | 43 +- .../status_content/status_content.js | 87 +-- .../status_content/status_content.vue | 16 +- .../status_history_modal.js | 32 +- .../status_history_modal.vue | 10 +- .../status_popover/status_popover.js | 25 +- .../status_popover/status_popover.vue | 7 +- .../sticker_picker/sticker_picker.js | 41 +- .../sticker_picker/sticker_picker.vue | 13 +- src/components/still-image/still-image.js | 44 +- src/components/still-image/still-image.vue | 2 +- src/components/swipe_click/swipe_click.js | 20 +- src/components/tag_timeline/tag_timeline.js | 30 +- src/components/tag_timeline/tag_timeline.vue | 2 +- .../terms_of_service_panel.js | 2 +- .../terms_of_service_panel.vue | 6 +- src/components/thread_tree/thread_tree.js | 43 +- src/components/thread_tree/thread_tree.vue | 39 +- src/components/timeago/timeago.vue | 29 +- src/components/timeline/timeline.js | 208 ++++--- src/components/timeline/timeline.vue | 8 +- .../timeline/timeline_quick_settings.js | 72 ++- .../timeline/timeline_quick_settings.vue | 7 +- src/components/timeline_menu/timeline_menu.js | 20 +- .../timeline_menu/timeline_menu.vue | 11 +- .../timeline_menu/timeline_menu_content.js | 18 +- .../timeline_menu/timeline_menu_content.vue | 36 +- .../timeline_menu_content.js | 15 +- .../timeline_menu_content.vue | 36 +- .../timeline_menu_tabs/timeline_menu_tabs.js | 20 +- .../timeline_menu_tabs/timeline_menu_tabs.vue | 2 +- src/components/user_avatar/user_avatar.js | 28 +- src/components/user_avatar/user_avatar.vue | 1 - src/components/user_card/user_card.js | 133 +++-- src/components/user_card/user_card.vue | 27 +- .../user_list_popover/user_list_popover.js | 14 +- .../user_list_popover/user_list_popover.vue | 15 +- src/components/user_panel/user_panel.js | 6 +- src/components/user_profile/user_profile.js | 85 +-- src/components/user_profile/user_profile.vue | 7 +- .../user_reporting_modal.js | 50 +- .../user_reporting_modal.vue | 6 +- .../video_attachment/video_attachment.js | 11 +- src/components/who_to_follow/who_to_follow.js | 18 +- .../who_to_follow/who_to_follow.vue | 3 +- .../who_to_follow_panel.js | 47 +- .../who_to_follow_panel.vue | 54 +- src/directives/body_scroll_lock.js | 22 +- src/lib/persisted_state.js | 47 +- src/lib/push_notifications_plugin.js | 24 +- src/main.js | 30 +- src/modules/announcements.js | 63 +- src/modules/api.js | 235 +++++--- src/modules/auth_flow.js | 16 +- src/modules/config.js | 104 ++-- src/modules/editStatus.js | 8 +- src/modules/errors.js | 2 +- src/modules/instance.js | 110 ++-- src/modules/interface.js | 95 +-- src/modules/lists.js | 51 +- src/modules/media_viewer.js | 14 +- src/modules/oauth.js | 12 +- src/modules/oauth_tokens.js | 21 +- src/modules/polls.js | 28 +- src/modules/postStatus.js | 8 +- src/modules/reports.js | 45 +- src/modules/serverSideConfig.js | 68 +-- src/modules/statusHistory.js | 8 +- src/modules/statuses.js | 517 ++++++++++------ src/modules/tags.js | 24 +- src/modules/users.js | 382 +++++++----- .../announcements_fetcher.service.js | 12 +- src/services/api/api.service.js | 564 +++++++++++------- .../backend_interactor_service.js | 53 +- src/services/color_convert/color_convert.js | 37 +- src/services/completion/completion.js | 34 +- .../component_utils/component_utils.js | 8 +- src/services/date_utils/date_utils.js | 6 +- .../desktop_notification_utils.js | 14 +- .../entity_normalizer.service.js | 76 ++- src/services/errors/errors.js | 10 +- src/services/export_import/export_import.js | 16 +- .../favicon_service/favicon_service.js | 48 +- .../file_size_format/file_size_format.js | 5 +- src/services/file_type/file_type.service.js | 4 +- .../follow_manipulate/follow_manipulate.js | 102 ++-- .../follow_request_fetcher.service.js | 14 +- .../gesture_service/gesture_service.js | 57 +- .../html_line_converter.service.js | 69 ++- .../html_tree_converter.service.js | 25 +- .../html_converter/utility.service.js | 11 +- .../lists_fetcher/lists_fetcher.service.js | 12 +- src/services/locale/locale.service.js | 27 +- src/services/matcher/matcher.service.js | 5 +- src/services/new_api/mfa.js | 36 +- src/services/new_api/oauth.js | 113 ++-- src/services/new_api/password_reset.js | 12 +- .../notification_utils/notification_utils.js | 60 +- .../notifications_fetcher.service.js | 10 +- .../offset_finder/offset_finder.service.js | 23 +- .../promise_interval/promise_interval.js | 5 +- src/services/push/push.js | 153 +++-- .../reports_fetcher.service.js | 28 +- src/services/resettable_async_component.js | 15 +- src/services/ruffle_service/ruffle_service.js | 65 +- src/services/status_parser/status_parser.js | 5 +- .../status_poster/status_poster.service.js | 50 +- src/services/style_setter/style_setter.js | 414 +++++++------ src/services/theme_data/theme_data.service.js | 371 ++++++------ .../timeline_fetcher.service.js | 61 +- .../user_highlighter/user_highlighter.js | 21 +- .../user_profile_link_generator.js | 11 +- src/services/version/version.service.js | 3 +- src/services/window_utils/window_utils.js | 1 - src/sw.js | 40 +- test/unit/specs/boot/routes.spec.js | 40 +- .../unit/specs/components/emoji_input.spec.js | 14 +- .../specs/components/rich_content.spec.js | 97 ++- .../specs/components/user_profile.spec.js | 16 +- test/unit/specs/modules/lists.spec.js | 14 +- test/unit/specs/modules/statuses.spec.js | 275 +++++++-- test/unit/specs/modules/users.spec.js | 14 +- .../services/completion/completion.spec.js | 25 +- .../services/date_utils/date_utils.spec.js | 42 +- .../entity_normalizer.spec.js | 420 +++++++------ .../gesture_service/gesture_service.spec.js | 41 +- .../html_line_converter.spec.js | 65 +- .../html_tree_converter.spec.js | 77 +-- .../services/html_converter/utility.spec.js | 9 +- .../notification_utils.spec.js | 8 +- .../services/theme_data/sanity_checks.spec.js | 2 +- .../services/theme_data/theme_data.spec.js | 11 +- .../user_profile_link_generator.spec.js | 9 +- 364 files changed, 9181 insertions(+), 6305 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..983b1f483 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "trailingComma": "none", + "singleQuote": true, + "semi": false, + "singleAttributePerLine": true +} diff --git a/src/App.js b/src/App.js index d4b3b41aa..83e535b90 100644 --- a/src/App.js +++ b/src/App.js @@ -24,7 +24,9 @@ export default { components: { UserPanel, NavPanel, - Notifications: defineAsyncComponent(() => import('./components/notifications/notifications.vue')), + Notifications: defineAsyncComponent(() => + import('./components/notifications/notifications.vue') + ), InstanceSpecificPanel, FeaturesPanel, WhoToFollowPanel, @@ -44,17 +46,20 @@ export default { data: () => ({ mobileActivePanel: 'timeline' }), - created () { + created() { // Load the locale from the storage const val = this.$store.getters.mergedConfig.interfaceLanguage - this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val }) + this.$store.dispatch('setOption', { + name: 'interfaceLanguage', + value: val + }) window.addEventListener('resize', this.updateMobileState) }, - unmounted () { + unmounted() { window.removeEventListener('resize', this.updateMobileState) }, computed: { - classes () { + classes() { return [ { '-reverse': this.reverseLayout, @@ -64,48 +69,76 @@ export default { '-' + this.layoutType ] }, - currentUser () { return this.$store.state.users.currentUser }, - userBackground () { return this.currentUser.background_image }, - instanceBackground () { + currentUser() { + return this.$store.state.users.currentUser + }, + userBackground() { + return this.currentUser.background_image + }, + instanceBackground() { return this.mergedConfig.hideInstanceWallpaper ? null : this.$store.state.instance.background }, - background () { return this.userBackground || this.instanceBackground }, - bgStyle () { + background() { + return this.userBackground || this.instanceBackground + }, + bgStyle() { if (this.background) { return { '--body-background-image': `url(${this.background})` } } }, - suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled }, - showInstanceSpecificPanel () { - return this.$store.state.instance.showInstanceSpecificPanel && + suggestionsEnabled() { + return this.$store.state.instance.suggestionsEnabled + }, + showInstanceSpecificPanel() { + return ( + this.$store.state.instance.showInstanceSpecificPanel && !this.$store.getters.mergedConfig.hideISP && this.$store.state.instance.instanceSpecificPanelContent + ) }, - newPostButtonShown () { - return this.$store.getters.mergedConfig.alwaysShowNewPostButton || this.layoutType === 'mobile' + newPostButtonShown() { + return ( + this.$store.getters.mergedConfig.alwaysShowNewPostButton || + this.layoutType === 'mobile' + ) }, - showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel }, - editingAvailable () { return this.$store.state.instance.editingAvailable }, - layoutType () { return this.$store.state.interface.layoutType }, - privateMode () { return this.$store.state.instance.private }, - reverseLayout () { - const { thirdColumnMode, sidebarRight: reverseSetting } = this.$store.getters.mergedConfig + showFeaturesPanel() { + return this.$store.state.instance.showFeaturesPanel + }, + editingAvailable() { + return this.$store.state.instance.editingAvailable + }, + layoutType() { + return this.$store.state.interface.layoutType + }, + privateMode() { + return this.$store.state.instance.private + }, + reverseLayout() { + const { thirdColumnMode, sidebarRight: reverseSetting } = + this.$store.getters.mergedConfig if (this.layoutType !== 'wide') { return reverseSetting } else { - return thirdColumnMode === 'notifications' ? reverseSetting : !reverseSetting + return thirdColumnMode === 'notifications' + ? reverseSetting + : !reverseSetting } }, - noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders }, - showScrollbars () { return this.$store.getters.mergedConfig.showScrollbars }, + noSticky() { + return this.$store.getters.mergedConfig.disableStickyHeaders + }, + showScrollbars() { + return this.$store.getters.mergedConfig.showScrollbars + }, ...mapGetters(['mergedConfig']) }, methods: { - updateMobileState () { + updateMobileState() { this.$store.dispatch('setLayoutWidth', windowWidth()) this.$store.dispatch('setLayoutHeight', windowHeight()) } diff --git a/src/App.vue b/src/App.vue index 80ebb525c..65b6e35b1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -43,7 +43,7 @@ :to="{ name: 'login' }" class="panel-body" > - {{ $t("login.hint") }} + {{ $t('login.hint') }} diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 4bafca1d6..c09403baf 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -3,13 +3,19 @@ import { createApp } from 'vue' import { createRouter, createWebHistory } from 'vue-router' import vClickOutside from 'click-outside-vue3' -import { FontAwesomeIcon, FontAwesomeLayers } from '@fortawesome/vue-fontawesome' +import { + FontAwesomeIcon, + FontAwesomeLayers +} from '@fortawesome/vue-fontawesome' import App from '../App.vue' import routes from './routes' import VBodyScrollLock from 'src/directives/body_scroll_lock' -import { windowWidth, windowHeight } from '../services/window_utils/window_utils' +import { + windowWidth, + windowHeight +} from '../services/window_utils/window_utils' import { getOrCreateApp, getClientToken } from '../services/new_api/oauth.js' import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import { CURRENT_VERSION } from '../services/theme_data/theme_data.service.js' @@ -23,7 +29,9 @@ const parsedInitialResults = () => { return null } if (!staticInitialResults) { - staticInitialResults = JSON.parse(document.getElementById('initial-results').textContent) + staticInitialResults = JSON.parse( + document.getElementById('initial-results').textContent + ) } return staticInitialResults } @@ -71,18 +79,30 @@ const getInstanceConfig = async ({ store }) => { const textlimit = data.max_toot_chars const vapidPublicKey = data.pleroma.vapid_public_key - store.dispatch('setInstanceOption', { name: 'textlimit', value: textlimit }) - store.dispatch('setInstanceOption', { name: 'accountApprovalRequired', value: data.approval_required }) + store.dispatch('setInstanceOption', { + name: 'textlimit', + value: textlimit + }) + store.dispatch('setInstanceOption', { + name: 'accountApprovalRequired', + value: data.approval_required + }) // don't override cookie if set if (!Cookies.get('userLanguage')) { - store.dispatch('setOption', { name: 'interfaceLanguage', value: resolveLanguage(data.languages) }) + store.dispatch('setOption', { + name: 'interfaceLanguage', + value: resolveLanguage(data.languages) + }) } if (vapidPublicKey) { - store.dispatch('setInstanceOption', { name: 'vapidPublicKey', value: vapidPublicKey }) + store.dispatch('setInstanceOption', { + name: 'vapidPublicKey', + value: vapidPublicKey + }) } } else { - throw (res) + throw res } } catch (error) { console.error('Could not load instance config, potentially fatal') @@ -97,10 +117,12 @@ const getBackendProvidedConfig = async ({ store }) => { const data = await res.json() return data.pleroma_fe } else { - throw (res) + throw res } } catch (error) { - console.error('Could not load backend-provided frontend config, potentially fatal') + console.error( + 'Could not load backend-provided frontend config, potentially fatal' + ) console.error(error) } } @@ -111,7 +133,7 @@ const getStaticConfig = async () => { if (res.ok) { return res.json() } else { - throw (res) + throw res } } catch (error) { console.warn('Failed to load static/config.json, continuing without it.') @@ -154,16 +176,12 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => { store.dispatch('setInstanceOption', { name: 'logoMask', - value: typeof config.logoMask === 'undefined' - ? true - : config.logoMask + value: typeof config.logoMask === 'undefined' ? true : config.logoMask }) store.dispatch('setInstanceOption', { name: 'logoMargin', - value: typeof config.logoMargin === 'undefined' - ? 0 - : config.logoMargin + value: typeof config.logoMargin === 'undefined' ? 0 : config.logoMargin }) copyInstanceOption('logoLeft') store.commit('authFlow/setInitialStrategy', config.loginMethod) @@ -191,7 +209,7 @@ const getTOS = async ({ store }) => { const html = await res.text() store.dispatch('setInstanceOption', { name: 'tos', value: html }) } else { - throw (res) + throw res } } catch (e) { console.warn("Can't load TOS") @@ -204,9 +222,12 @@ const getInstancePanel = async ({ store }) => { const res = await preloadFetch('/instance/panel.html') if (res.ok) { const html = await res.text() - store.dispatch('setInstanceOption', { name: 'instanceSpecificPanelContent', value: html }) + store.dispatch('setInstanceOption', { + name: 'instanceSpecificPanelContent', + value: html + }) } else { - throw (res) + throw res } } catch (e) { console.warn("Can't load instance panel") @@ -219,25 +240,30 @@ const getStickers = async ({ store }) => { const res = await window.fetch('/static/stickers.json') if (res.ok) { const values = await res.json() - const stickers = (await Promise.all( - Object.entries(values).map(async ([name, path]) => { - const resPack = await window.fetch(path + 'pack.json') - var meta = {} - if (resPack.ok) { - meta = await resPack.json() - } - return { - pack: name, - path, - meta - } - }) - )).sort((a, b) => { + const stickers = ( + await Promise.all( + Object.entries(values).map(async ([name, path]) => { + const resPack = await window.fetch(path + 'pack.json') + var meta = {} + if (resPack.ok) { + meta = await resPack.json() + } + return { + pack: name, + path, + meta + } + }) + ) + ).sort((a, b) => { return a.meta.title.localeCompare(b.meta.title) }) - store.dispatch('setInstanceOption', { name: 'stickers', value: stickers }) + store.dispatch('setInstanceOption', { + name: 'stickers', + value: stickers + }) } else { - throw (res) + throw res } } catch (e) { console.warn("Can't load stickers") @@ -252,13 +278,19 @@ const getAppSecret = async ({ store }) => { .then((app) => getClientToken({ ...app, instance: instance.server })) .then((token) => { commit('setAppToken', token.access_token) - commit('setBackendInteractor', backendInteractorService(store.getters.getToken())) + commit( + 'setBackendInteractor', + backendInteractorService(store.getters.getToken()) + ) }) } const resolveStaffAccounts = ({ store, accounts }) => { - const nicknames = accounts.map(uri => uri.split('/').pop()) - store.dispatch('setInstanceOption', { name: 'staffAccounts', value: nicknames }) + const nicknames = accounts.map((uri) => uri.split('/').pop()) + store.dispatch('setInstanceOption', { + name: 'staffAccounts', + value: nicknames + }) } const getNodeInfo = async ({ store }) => { @@ -268,65 +300,137 @@ const getNodeInfo = async ({ store }) => { const data = await res.json() const metadata = data.metadata const features = metadata.features - store.dispatch('setInstanceOption', { name: 'name', value: metadata.nodeName }) - store.dispatch('setInstanceOption', { name: 'registrationOpen', value: data.openRegistrations }) - store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: features.includes('media_proxy') }) - store.dispatch('setInstanceOption', { name: 'safeDM', value: features.includes('safe_dm_mentions') }) - store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: features.includes('polls') }) - store.dispatch('setInstanceOption', { name: 'editingAvailable', value: features.includes('editing') }) - store.dispatch('setInstanceOption', { name: 'pollLimits', value: metadata.pollLimits }) - store.dispatch('setInstanceOption', { name: 'mailerEnabled', value: metadata.mailerEnabled }) - store.dispatch('setInstanceOption', { name: 'translationEnabled', value: features.includes('akkoma:machine_translation') }) + store.dispatch('setInstanceOption', { + name: 'name', + value: metadata.nodeName + }) + store.dispatch('setInstanceOption', { + name: 'registrationOpen', + value: data.openRegistrations + }) + store.dispatch('setInstanceOption', { + name: 'mediaProxyAvailable', + value: features.includes('media_proxy') + }) + store.dispatch('setInstanceOption', { + name: 'safeDM', + value: features.includes('safe_dm_mentions') + }) + store.dispatch('setInstanceOption', { + name: 'pollsAvailable', + value: features.includes('polls') + }) + store.dispatch('setInstanceOption', { + name: 'editingAvailable', + value: features.includes('editing') + }) + store.dispatch('setInstanceOption', { + name: 'pollLimits', + value: metadata.pollLimits + }) + store.dispatch('setInstanceOption', { + name: 'mailerEnabled', + value: metadata.mailerEnabled + }) + store.dispatch('setInstanceOption', { + name: 'translationEnabled', + value: features.includes('akkoma:machine_translation') + }) const uploadLimits = metadata.uploadLimits - store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadLimits.general) }) - store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(uploadLimits.avatar) }) - store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(uploadLimits.background) }) - store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadLimits.banner) }) - store.dispatch('setInstanceOption', { name: 'fieldsLimits', value: metadata.fieldsLimits }) + store.dispatch('setInstanceOption', { + name: 'uploadlimit', + value: parseInt(uploadLimits.general) + }) + store.dispatch('setInstanceOption', { + name: 'avatarlimit', + value: parseInt(uploadLimits.avatar) + }) + store.dispatch('setInstanceOption', { + name: 'backgroundlimit', + value: parseInt(uploadLimits.background) + }) + store.dispatch('setInstanceOption', { + name: 'bannerlimit', + value: parseInt(uploadLimits.banner) + }) + store.dispatch('setInstanceOption', { + name: 'fieldsLimits', + value: metadata.fieldsLimits + }) - store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames }) - store.dispatch('setInstanceOption', { name: 'postFormats', value: metadata.postFormats }) + store.dispatch('setInstanceOption', { + name: 'restrictedNicknames', + value: metadata.restrictedNicknames + }) + store.dispatch('setInstanceOption', { + name: 'postFormats', + value: metadata.postFormats + }) const suggestions = metadata.suggestions - store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled }) - store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web }) + store.dispatch('setInstanceOption', { + name: 'suggestionsEnabled', + value: suggestions.enabled + }) + store.dispatch('setInstanceOption', { + name: 'suggestionsWeb', + value: suggestions.web + }) const software = data.software - store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version }) - store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: software.name === 'pleroma' }) + store.dispatch('setInstanceOption', { + name: 'backendVersion', + value: software.version + }) + store.dispatch('setInstanceOption', { + name: 'pleromaBackend', + value: software.name === 'pleroma' + }) const priv = metadata.private store.dispatch('setInstanceOption', { name: 'private', value: priv }) const frontendVersion = window.___pleromafe_commit_hash - store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion }) + store.dispatch('setInstanceOption', { + name: 'frontendVersion', + value: frontendVersion + }) const federation = metadata.federation store.dispatch('setInstanceOption', { name: 'tagPolicyAvailable', - value: typeof federation.mrf_policies === 'undefined' - ? false - : metadata.federation.mrf_policies.includes('TagPolicy') + value: + typeof federation.mrf_policies === 'undefined' + ? false + : metadata.federation.mrf_policies.includes('TagPolicy') }) - store.dispatch('setInstanceOption', { name: 'federationPolicy', value: federation }) - store.dispatch('setInstanceOption', { name: 'localBubbleInstances', value: metadata.localBubbleInstances }) + store.dispatch('setInstanceOption', { + name: 'federationPolicy', + value: federation + }) + store.dispatch('setInstanceOption', { + name: 'localBubbleInstances', + value: metadata.localBubbleInstances + }) store.dispatch('setInstanceOption', { name: 'federating', - value: typeof federation.enabled === 'undefined' - ? true - : federation.enabled + value: + typeof federation.enabled === 'undefined' ? true : federation.enabled }) const accountActivationRequired = metadata.accountActivationRequired - store.dispatch('setInstanceOption', { name: 'accountActivationRequired', value: accountActivationRequired }) + store.dispatch('setInstanceOption', { + name: 'accountActivationRequired', + value: accountActivationRequired + }) const accounts = metadata.staffAccounts resolveStaffAccounts({ store, accounts }) } else { - throw (res) + throw res } } catch (e) { console.warn('Could not load nodeinfo') @@ -336,11 +440,16 @@ const getNodeInfo = async ({ store }) => { const setConfig = async ({ store }) => { // apiConfig, staticConfig - const configInfos = await Promise.all([getBackendProvidedConfig({ store }), getStaticConfig()]) + const configInfos = await Promise.all([ + getBackendProvidedConfig({ store }), + getStaticConfig() + ]) const apiConfig = configInfos[0] const staticConfig = configInfos[1] - await setSettings({ store, apiConfig, staticConfig }).then(getAppSecret({ store })) + await setSettings({ store, apiConfig, staticConfig }).then( + getAppSecret({ store }) + ) } const checkOAuthToken = async ({ store }) => { @@ -363,7 +472,10 @@ const afterStoreSetup = async ({ store, i18n }) => { FaviconService.initFaviconService() const overrides = window.___pleromafe_dev_overrides || {} - const server = (typeof overrides.target !== 'undefined') ? overrides.target : window.location.origin + const server = + typeof overrides.target !== 'undefined' + ? overrides.target + : window.location.origin store.dispatch('setInstanceOption', { name: 'server', value: server }) await setConfig({ store }) @@ -373,7 +485,10 @@ const afterStoreSetup = async ({ store, i18n }) => { const customThemePresent = customThemeSource || customTheme if (customThemePresent) { - if (customThemeSource && customThemeSource.themeEngineVersion === CURRENT_VERSION) { + if ( + customThemeSource && + customThemeSource.themeEngineVersion === CURRENT_VERSION + ) { applyTheme(customThemeSource) } else { applyTheme(customTheme) @@ -404,7 +519,7 @@ const afterStoreSetup = async ({ store, i18n }) => { history: createWebHistory(), routes: routes(store), scrollBehavior: (to, _from, savedPosition) => { - if (to.matched.some(m => m.meta.dontScroll)) { + if (to.matched.some((m) => m.meta.dontScroll)) { return {} } diff --git a/src/boot/routes.js b/src/boot/routes.js index 93a94a9b6..e22946639 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -35,51 +35,145 @@ export default (store) => { } let routes = [ - { name: 'root', + { + name: 'root', path: '/', - redirect: _to => { - return (store.state.users.currentUser - ? store.state.instance.redirectRootLogin - : store.state.instance.redirectRootNoLogin) || '/main/all' + redirect: (_to) => { + return ( + (store.state.users.currentUser + ? store.state.instance.redirectRootLogin + : store.state.instance.redirectRootNoLogin) || '/main/all' + ) } }, - { name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline }, - { name: 'public-timeline', path: '/main/public', component: PublicTimeline }, - { name: 'bubble-timeline', path: '/main/bubble', component: BubbleTimeline }, - { name: 'friends', path: '/main/friends', component: FriendsTimeline, beforeEnter: validateAuthenticatedRoute }, + { + name: 'public-external-timeline', + path: '/main/all', + component: PublicAndExternalTimeline + }, + { + name: 'public-timeline', + path: '/main/public', + component: PublicTimeline + }, + { + name: 'bubble-timeline', + path: '/main/bubble', + component: BubbleTimeline + }, + { + name: 'friends', + path: '/main/friends', + component: FriendsTimeline, + beforeEnter: validateAuthenticatedRoute + }, { name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline }, { name: 'bookmarks', path: '/bookmarks', component: BookmarkTimeline }, - { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, - { name: 'remote-user-profile-acct', + { + name: 'conversation', + path: '/notice/:id', + component: ConversationPage, + meta: { dontScroll: true } + }, + { + name: 'remote-user-profile-acct', path: '/remote-users/:_(@)?:username([^/@]+)@:hostname([^/@]+)', component: RemoteUserResolver, beforeEnter: validateAuthenticatedRoute }, - { name: 'remote-user-profile', + { + name: 'remote-user-profile', path: '/remote-users/:hostname/:username', component: RemoteUserResolver, beforeEnter: validateAuthenticatedRoute }, - { name: 'external-user-profile', path: '/users/:id', component: UserProfile, meta: { dontScroll: true } }, - { name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute }, - { name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute }, + { + name: 'external-user-profile', + path: '/users/:id', + component: UserProfile, + meta: { dontScroll: true } + }, + { + name: 'interactions', + path: '/users/:username/interactions', + component: Interactions, + beforeEnter: validateAuthenticatedRoute + }, + { + name: 'dms', + path: '/users/:username/dms', + component: DMs, + beforeEnter: validateAuthenticatedRoute + }, { name: 'registration', path: '/registration', component: Registration }, - { name: 'registration-request-sent', path: '/registration-request-sent', component: RegistrationRequestSent }, - { name: 'awaiting-email-confirmation', path: '/awaiting-email-confirmation', component: AwaitingEmailConfirmation }, - { name: 'password-reset', path: '/password-reset', component: PasswordReset, props: true }, - { name: 'registration-token', path: '/registration/:token', component: Registration }, - { name: 'friend-requests', path: '/friend-requests', component: FollowRequests, beforeEnter: validateAuthenticatedRoute }, - { name: 'notifications', path: '/:username/notifications', component: Notifications, props: () => ({ disableTeleport: true }), beforeEnter: validateAuthenticatedRoute }, + { + name: 'registration-request-sent', + path: '/registration-request-sent', + component: RegistrationRequestSent + }, + { + name: 'awaiting-email-confirmation', + path: '/awaiting-email-confirmation', + component: AwaitingEmailConfirmation + }, + { + name: 'password-reset', + path: '/password-reset', + component: PasswordReset, + props: true + }, + { + name: 'registration-token', + path: '/registration/:token', + component: Registration + }, + { + name: 'friend-requests', + path: '/friend-requests', + component: FollowRequests, + beforeEnter: validateAuthenticatedRoute + }, + { + name: 'notifications', + path: '/:username/notifications', + component: Notifications, + props: () => ({ disableTeleport: true }), + beforeEnter: validateAuthenticatedRoute + }, { name: 'login', path: '/login', component: AuthForm }, - { name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, - { name: 'search', path: '/search', component: Search, props: (route) => ({ query: route.query.query }) }, - { name: 'who-to-follow', path: '/who-to-follow', component: WhoToFollow, beforeEnter: validateAuthenticatedRoute }, + { + name: 'oauth-callback', + path: '/oauth-callback', + component: OAuthCallback, + props: (route) => ({ code: route.query.code }) + }, + { + name: 'search', + path: '/search', + component: Search, + props: (route) => ({ query: route.query.query }) + }, + { + name: 'who-to-follow', + path: '/who-to-follow', + component: WhoToFollow, + beforeEnter: validateAuthenticatedRoute + }, { name: 'about', path: '/about', component: About }, { name: 'lists', path: '/lists', component: Lists }, { name: 'list-timeline', path: '/lists/:id', component: ListTimeline }, { name: 'list-edit', path: '/lists/:id/edit', component: ListEdit }, - { name: 'announcements', path: '/announcements', component: AnnouncementsPage }, - { name: 'user-profile', path: '/:_(users)?/:name', component: UserProfile, meta: { dontScroll: true } } + { + name: 'announcements', + path: '/announcements', + component: AnnouncementsPage + }, + { + name: 'user-profile', + path: '/:_(users)?/:name', + component: UserProfile, + meta: { dontScroll: true } + } ] return routes diff --git a/src/components/about/about.js b/src/components/about/about.js index 7998c2d37..c8bc9f51f 100644 --- a/src/components/about/about.js +++ b/src/components/about/about.js @@ -15,13 +15,17 @@ const About = { LocalBubblePanel }, computed: { - showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel }, - showInstanceSpecificPanel () { - return this.$store.state.instance.showInstanceSpecificPanel && + showFeaturesPanel() { + return this.$store.state.instance.showFeaturesPanel + }, + showInstanceSpecificPanel() { + return ( + this.$store.state.instance.showInstanceSpecificPanel && !this.$store.getters.mergedConfig.hideISP && this.$store.state.instance.instanceSpecificPanelContent + ) }, - showLocalBubblePanel () { + showLocalBubblePanel() { return this.$store.state.instance.localBubbleInstances.length > 0 } } diff --git a/src/components/about/about.vue b/src/components/about/about.vue index df9bb1966..9126b3ff6 100644 --- a/src/components/about/about.vue +++ b/src/components/about/about.vue @@ -9,7 +9,6 @@ - + - + diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js index 0f3484748..92b8679f2 100644 --- a/src/components/account_actions/account_actions.js +++ b/src/components/account_actions/account_actions.js @@ -3,19 +3,13 @@ import Popover from '../popover/popover.vue' import ConfirmModal from '../confirm_modal/confirm_modal.vue' import { library } from '@fortawesome/fontawesome-svg-core' import { mapState } from 'vuex' -import { - faEllipsisV -} from '@fortawesome/free-solid-svg-icons' +import { faEllipsisV } from '@fortawesome/free-solid-svg-icons' -library.add( - faEllipsisV -) +library.add(faEllipsisV) const AccountActions = { - props: [ - 'user', 'relationship' - ], - data () { + props: ['user', 'relationship'], + data() { return { showingConfirmBlock: false } @@ -26,56 +20,59 @@ const AccountActions = { ConfirmModal }, methods: { - refetchRelationship () { + refetchRelationship() { return this.$store.dispatch('fetchUserRelationship', this.user.id) }, - showConfirmBlock () { + showConfirmBlock() { this.showingConfirmBlock = true }, - hideConfirmBlock () { + hideConfirmBlock() { this.showingConfirmBlock = false }, - showRepeats () { + showRepeats() { this.$store.dispatch('showReblogs', this.user.id) }, - hideRepeats () { + hideRepeats() { this.$store.dispatch('hideReblogs', this.user.id) }, - blockUser () { + blockUser() { if (!this.shouldConfirmBlock) { this.doBlockUser() } else { this.showConfirmBlock() } }, - doBlockUser () { + doBlockUser() { this.$store.dispatch('blockUser', this.user.id) this.hideConfirmBlock() }, - unblockUser () { + unblockUser() { this.$store.dispatch('unblockUser', this.user.id) }, - removeUserFromFollowers () { + removeUserFromFollowers() { this.$store.dispatch('removeUserFromFollowers', this.user.id) }, - reportUser () { + reportUser() { this.$store.dispatch('openUserReportingModal', { userId: this.user.id }) }, - muteDomain () { - this.$store.dispatch('muteDomain', this.user.screen_name.split('@')[1]) + muteDomain() { + this.$store + .dispatch('muteDomain', this.user.screen_name.split('@')[1]) .then(() => this.refetchRelationship()) }, - unmuteDomain () { - this.$store.dispatch('unmuteDomain', this.user.screen_name.split('@')[1]) + unmuteDomain() { + this.$store + .dispatch('unmuteDomain', this.user.screen_name.split('@')[1]) .then(() => this.refetchRelationship()) } }, computed: { - shouldConfirmBlock () { + shouldConfirmBlock() { return this.$store.getters.mergedConfig.modalOnBlock }, ...mapState({ - pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable + pleromaChatMessagesAvailable: (state) => + state.instance.pleromaChatMessagesAvailable }) } } diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue index 126f6fa99..1ad96c7fe 100644 --- a/src/components/account_actions/account_actions.vue +++ b/src/components/account_actions/account_actions.vue @@ -6,7 +6,7 @@ :bound-to="{ x: 'container' }" remove-padding > -