Merge pull request '[PR]: Option to disable swiping' (#10367) from Freeplay/calckey:swiper into develop

Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10367
This commit is contained in:
Kainoa Kanter 2023-06-27 02:52:35 +00:00
commit b43f6a7add
16 changed files with 53 additions and 49 deletions

View file

@ -1053,6 +1053,7 @@ recommendedInstancesDescription: "Recommended servers separated by line breaks t
caption: "Auto Caption" caption: "Auto Caption"
splash: "Splash Screen" splash: "Splash Screen"
updateAvailable: "There might be an update available!" updateAvailable: "There might be an update available!"
swipeOnMobile: "Allow swiping between pages"
swipeOnDesktop: "Allow mobile-style swiping on desktop" swipeOnDesktop: "Allow mobile-style swiping on desktop"
logoImageUrl: "Logo image URL" logoImageUrl: "Logo image URL"
showAdminUpdates: "Indicate a new Calckey version is avaliable (admin only)" showAdminUpdates: "Indicate a new Calckey version is avaliable (admin only)"

View file

@ -16,10 +16,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -16,10 +16,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -19,10 +19,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -17,10 +17,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -17,10 +17,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -21,10 +21,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -17,10 +17,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -18,10 +18,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -16,10 +16,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -17,10 +17,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -45,7 +45,10 @@
class="_formBlock" class="_formBlock"
>{{ i18n.ts.useReactionPickerForContextMenu }}</FormSwitch >{{ i18n.ts.useReactionPickerForContextMenu }}</FormSwitch
> >
<FormSwitch v-model="swipeOnDesktop" class="_formBlock">{{ <FormSwitch v-if="deviceKind !== 'desktop'" v-model="swipeOnMobile" class="_formBlock">{{
i18n.ts.swipeOnMobile
}}</FormSwitch>
<FormSwitch v-if="deviceKind === 'desktop'" v-model="swipeOnDesktop" class="_formBlock">{{
i18n.ts.swipeOnDesktop i18n.ts.swipeOnDesktop
}}</FormSwitch> }}</FormSwitch>
<FormSwitch v-model="enterSendsMessage" class="_formBlock">{{ <FormSwitch v-model="enterSendsMessage" class="_formBlock">{{
@ -253,6 +256,7 @@ import * as os from "@/os";
import { unisonReload } from "@/scripts/unison-reload"; import { unisonReload } from "@/scripts/unison-reload";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata"; import { definePageMetadata } from "@/scripts/page-metadata";
import { deviceKind } from "@/scripts/device-kind";
const lang = ref(localStorage.getItem("lang")); const lang = ref(localStorage.getItem("lang"));
const fontSize = ref(localStorage.getItem("fontSize")); const fontSize = ref(localStorage.getItem("fontSize"));
@ -339,6 +343,7 @@ const showUpdates = computed(defaultStore.makeGetterSetter("showUpdates"));
const swipeOnDesktop = computed( const swipeOnDesktop = computed(
defaultStore.makeGetterSetter("swipeOnDesktop") defaultStore.makeGetterSetter("swipeOnDesktop")
); );
const swipeOnMobile = computed(defaultStore.makeGetterSetter("swipeOnMobile"));
const showAdminUpdates = computed( const showAdminUpdates = computed(
defaultStore.makeGetterSetter("showAdminUpdates") defaultStore.makeGetterSetter("showAdminUpdates")
); );
@ -346,6 +351,10 @@ const showTimelineReplies = computed(
defaultStore.makeGetterSetter("showTimelineReplies") defaultStore.makeGetterSetter("showTimelineReplies")
); );
watch(swipeOnDesktop, () => {
defaultStore.set("swipeOnMobile", true);
});
watch(lang, () => { watch(lang, () => {
localStorage.setItem("lang", lang.value as string); localStorage.setItem("lang", lang.value as string);
localStorage.removeItem("locale"); localStorage.removeItem("locale");
@ -379,6 +388,7 @@ watch(
overridedDeviceKind, overridedDeviceKind,
showAds, showAds,
showUpdates, showUpdates,
swipeOnMobile,
swipeOnDesktop, swipeOnDesktop,
seperateRenoteQuote, seperateRenoteQuote,
showAdminUpdates, showAdminUpdates,

View file

@ -110,6 +110,7 @@ const defaultStoreSaveKeys: (keyof (typeof defaultStore)["state"])[] = [
"squareAvatars", "squareAvatars",
"numberOfPageCache", "numberOfPageCache",
"showUpdates", "showUpdates",
"swipeOnMobile",
"swipeOnDesktop", "swipeOnDesktop",
"showAdminUpdates", "showAdminUpdates",
"enableCustomKaTeXMacro", "enableCustomKaTeXMacro",

View file

@ -17,10 +17,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -46,10 +46,9 @@
:space-between="20" :space-between="20"
:virtual="true" :virtual="true"
:allow-touch-move=" :allow-touch-move="
!( defaultStore.state.swipeOnMobile &&
deviceKind === 'desktop' && (deviceKind !== 'desktop' ||
!defaultStore.state.swipeOnDesktop defaultStore.state.swipeOnDesktop)
)
" "
@swiper="setSwiperRef" @swiper="setSwiperRef"
@slide-change="onSlideChange" @slide-change="onSlideChange"

View file

@ -314,6 +314,10 @@ export const defaultStore = markRaw(
where: "device", where: "device",
default: false, default: false,
}, },
swipeOnMobile: {
where: "device",
default: true,
},
showAdminUpdates: { showAdminUpdates: {
where: "account", where: "account",
default: true, default: true,