From 48772f62cdee7b69dfe27d8a8d0dc94170c78646 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Thu, 15 Sep 2022 13:40:34 -0700 Subject: [PATCH] feat: :sparkles: Add setting for swipe behavior --- locales/en-US.yml | 1 + locales/ja-JP.yml | 1 + package.json | 2 +- packages/client/src/pages/about.vue | 3 ++- packages/client/src/pages/admin-file.vue | 3 ++- packages/client/src/pages/channels.vue | 3 ++- packages/client/src/pages/explore.vue | 3 ++- packages/client/src/pages/gallery/index.vue | 3 ++- packages/client/src/pages/instance-info.vue | 11 ++++++----- packages/client/src/pages/notifications.vue | 3 ++- packages/client/src/pages/pages.vue | 3 ++- packages/client/src/pages/settings/general.vue | 3 +++ .../client/src/pages/settings/preferences-backups.vue | 1 + packages/client/src/pages/timeline.vue | 3 ++- packages/client/src/pages/user/index.vue | 3 ++- packages/client/src/store.ts | 4 ++++ 16 files changed, 35 insertions(+), 15 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 6adb688968..e30b4d7a02 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -914,6 +914,7 @@ recommendedInstancesDescription: "Recommended instances seperated by line breaks caption: "Auto Caption" splash: "Splash Screen" updateAvailable: "There's an update available!" +swipeOnDesktop: "Allow mobile-style swiping on desktop" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server." diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 1abeb0f1d1..c8a1b43747 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -914,6 +914,7 @@ recommendedInstancesDescription: "推奨タイムラインに表示するため caption: "自動キャプション" splash: "スプラッシュスクリーン" updateAvailable: "アップデートがありますよ" +swipeOnDesktop: "デスクトップでモバイルスタイルのスワイプを可能にする" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" diff --git a/package.json b/package.json index 81dbbbd285..b5cbda9d24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "12.119.0-calc.1-rc.1", + "version": "12.119.0-calc.1-rc.2", "codename": "aqua", "repository": { "type": "git", diff --git a/packages/client/src/pages/about.vue b/packages/client/src/pages/about.vue index 7944241a70..d506cd3272 100644 --- a/packages/client/src/pages/about.vue +++ b/packages/client/src/pages/about.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -109,6 +109,7 @@ import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; import { iAmModerator } from '@/account'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/admin-file.vue b/packages/client/src/pages/admin-file.vue index f6c4184889..26aa62e35a 100644 --- a/packages/client/src/pages/admin-file.vue +++ b/packages/client/src/pages/admin-file.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -95,6 +95,7 @@ import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; import { acct } from '@/filters/user'; import { iAmAdmin, iAmModerator } from '@/account'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/channels.vue b/packages/client/src/pages/channels.vue index 1b23729629..ae43b6a44e 100644 --- a/packages/client/src/pages/channels.vue +++ b/packages/client/src/pages/channels.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -48,6 +48,7 @@ import { useRouter } from '@/router'; import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; import { i18n } from '@/i18n'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/explore.vue b/packages/client/src/pages/explore.vue index 114302e780..edcb1cd0e5 100644 --- a/packages/client/src/pages/explore.vue +++ b/packages/client/src/pages/explore.vue @@ -7,7 +7,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -53,6 +53,7 @@ import { deviceKind } from '@/scripts/device-kind'; import { i18n } from '@/i18n'; import { instance } from '@/instance'; import XUserList from '@/components/MkUserList.vue'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/gallery/index.vue b/packages/client/src/pages/gallery/index.vue index 805a2a633e..a1e275e7a1 100644 --- a/packages/client/src/pages/gallery/index.vue +++ b/packages/client/src/pages/gallery/index.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -59,6 +59,7 @@ import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; import { i18n } from '@/i18n'; import { useRouter } from '@/router'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/instance-info.vue b/packages/client/src/pages/instance-info.vue index 9f7fd55283..5c33d7793c 100644 --- a/packages/client/src/pages/instance-info.vue +++ b/packages/client/src/pages/instance-info.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -32,14 +32,14 @@ - + {{ i18n.ts.stopActivityDelivery }} {{ i18n.ts.blockThisInstance }} Refresh metadata - + @@ -62,7 +62,7 @@ - + @@ -73,7 +73,7 @@ - + host-meta @@ -151,6 +151,7 @@ import bytes from '@/filters/bytes'; import { iAmModerator } from '@/account'; import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; +import { defaultStore } from '@/store'; import { i18n } from '@/i18n'; import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkPagination from '@/components/MkPagination.vue'; diff --git a/packages/client/src/pages/notifications.vue b/packages/client/src/pages/notifications.vue index 30c07b0ea7..e1b25533db 100644 --- a/packages/client/src/pages/notifications.vue +++ b/packages/client/src/pages/notifications.vue @@ -13,7 +13,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -45,6 +45,7 @@ import * as os from '@/os'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/pages.vue b/packages/client/src/pages/pages.vue index 4027f8b238..8d8c06cb6e 100644 --- a/packages/client/src/pages/pages.vue +++ b/packages/client/src/pages/pages.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -48,6 +48,7 @@ import { useRouter } from '@/router'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 1f9cece924..ace0f9aa76 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -27,6 +27,7 @@ {{ i18n.ts.openImageInNewTab }} {{ i18n.ts.enableInfiniteScroll }} {{ i18n.ts.useReactionPickerForContextMenu }} + {{ i18n.ts.swipeOnDesktop }} {{ i18n.ts.enterSendsMessage }} {{ i18n.ts.disablePagesScript }} @@ -145,6 +146,7 @@ const enterSendsMessage = computed(defaultStore.makeGetterSetter('enterSendsMess const useReactionPickerForContextMenu = computed(defaultStore.makeGetterSetter('useReactionPickerForContextMenu')); const squareAvatars = computed(defaultStore.makeGetterSetter('squareAvatars')); const showUpdates = computed(defaultStore.makeGetterSetter('showUpdates')); +const swipeOnDesktop = computed(defaultStore.makeGetterSetter('swipeOnDesktop')); watch(lang, () => { localStorage.setItem('lang', lang.value as string); @@ -178,6 +180,7 @@ watch([ overridedDeviceKind, showAds, showUpdates, + swipeOnDesktop, ], async () => { await reloadAsk(); }); diff --git a/packages/client/src/pages/settings/preferences-backups.vue b/packages/client/src/pages/settings/preferences-backups.vue index 7f9b1d3999..a5a0531f78 100644 --- a/packages/client/src/pages/settings/preferences-backups.vue +++ b/packages/client/src/pages/settings/preferences-backups.vue @@ -84,6 +84,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [ 'squareAvatars', 'numberOfPageCache', 'showUpdates', + 'swipeOnDesktop', ]; const coldDeviceStorageSaveKeys: (keyof typeof ColdDeviceStorage.default)[] = [ 'lightTheme', diff --git a/packages/client/src/pages/timeline.vue b/packages/client/src/pages/timeline.vue index d194f3ee81..1702c33dc8 100644 --- a/packages/client/src/pages/timeline.vue +++ b/packages/client/src/pages/timeline.vue @@ -40,7 +40,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -79,6 +79,7 @@ import { instance } from '@/instance'; import { $i } from '@/account'; import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/pages/user/index.vue b/packages/client/src/pages/user/index.vue index a4bb5e7855..a59ace0ed4 100644 --- a/packages/client/src/pages/user/index.vue +++ b/packages/client/src/pages/user/index.vue @@ -6,7 +6,7 @@ :modules="[Virtual]" :space-between="20" :virtual="true" - :allow-touch-move="!(deviceKind === 'desktop')" + :allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)" @swiper="setSwiperRef" @slide-change="onSlideChange" > @@ -48,6 +48,7 @@ import { definePageMetadata } from '@/scripts/page-metadata'; import { deviceKind } from '@/scripts/device-kind'; import { i18n } from '@/i18n'; import { $i } from '@/account'; +import { defaultStore } from '@/store'; import 'swiper/scss'; import 'swiper/scss/virtual'; diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 7a09d76a91..d66970e4c0 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -255,6 +255,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, + swipeOnDesktop: { + where: 'device', + default: false, + }, })); // TODO: 他のタブと永続化されたstateを同期