From bac0951bd1608cbd97ba809a76a664590ce5efb3 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sun, 11 Feb 2024 12:07:35 +0900 Subject: [PATCH] type --- packages/frontend/src/pages/timeline.vue | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/pages/timeline.vue b/packages/frontend/src/pages/timeline.vue index 9a0782822ac4..f5f7c2ba405b 100644 --- a/packages/frontend/src/pages/timeline.vue +++ b/packages/frontend/src/pages/timeline.vue @@ -66,14 +66,14 @@ const tlComponent = shallowRef>(); const rootEl = shallowRef(); const queue = ref(0); -const srcWhenNotSignin = ref(isLocalTimelineAvailable ? 'local' : 'global'); -const src = computed({ +const srcWhenNotSignin = ref<'local' | 'global'>(isLocalTimelineAvailable ? 'local' : 'global'); +const src = computed<'home' | 'local' | 'social' | 'global' | `list:${string}`>({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin.value), set: (x) => saveSrc(x), }); -const withRenotes = computed({ +const withRenotes = computed({ get: () => defaultStore.reactiveState.tl.value.filter.withRenotes, - set: (x: boolean) => saveTlFilter('withRenotes', x), + set: (x) => saveTlFilter('withRenotes', x), }); // computed内での無限ループを防ぐためのフラグ @@ -88,7 +88,7 @@ const withReplies = computed({ return defaultStore.reactiveState.tl.value.filter.withReplies; } }, - set: (x: boolean) => saveTlFilter('withReplies', x), + set: (x) => saveTlFilter('withReplies', x), }); const onlyFiles = computed({ get: () => { @@ -98,7 +98,7 @@ const onlyFiles = computed({ return defaultStore.reactiveState.tl.value.filter.onlyFiles; } }, - set: (x: boolean) => saveTlFilter('onlyFiles', x), + set: (x) => saveTlFilter('onlyFiles', x), }); watch([withReplies, onlyFiles], ([withRepliesTo, onlyFilesTo]) => { @@ -111,9 +111,9 @@ watch([withReplies, onlyFiles], ([withRepliesTo, onlyFilesTo]) => { } }); -const withSensitive = computed({ +const withSensitive = computed({ get: () => defaultStore.reactiveState.tl.value.filter.withSensitive, - set: (x: boolean) => saveTlFilter('withSensitive', x), + set: (x) => saveTlFilter('withSensitive', x), }); watch(src, () => { @@ -208,7 +208,9 @@ function saveSrc(newSrc: 'home' | 'local' | 'social' | 'global' | `list:${string } defaultStore.set('tl', out); - srcWhenNotSignin.value = newSrc; + if (['local', 'global'].includes(newSrc)) { + srcWhenNotSignin.value = newSrc as 'local' | 'global'; + } } function saveTlFilter(key: keyof typeof defaultStore.state.tl.filter, newValue: boolean) {