Skip to content

Commit

Permalink
type
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Feb 11, 2024
1 parent 92b2165 commit bac0951
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/frontend/src/pages/timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ const tlComponent = shallowRef<InstanceType<typeof MkTimeline>>();
const rootEl = shallowRef<HTMLElement>();

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<boolean>({
get: () => defaultStore.reactiveState.tl.value.filter.withRenotes,
set: (x: boolean) => saveTlFilter('withRenotes', x),
set: (x) => saveTlFilter('withRenotes', x),
});

// computed内での無限ループを防ぐためのフラグ
Expand All @@ -88,7 +88,7 @@ const withReplies = computed<boolean>({
return defaultStore.reactiveState.tl.value.filter.withReplies;
}
},
set: (x: boolean) => saveTlFilter('withReplies', x),
set: (x) => saveTlFilter('withReplies', x),
});
const onlyFiles = computed<boolean>({
get: () => {
Expand All @@ -98,7 +98,7 @@ const onlyFiles = computed<boolean>({
return defaultStore.reactiveState.tl.value.filter.onlyFiles;
}
},
set: (x: boolean) => saveTlFilter('onlyFiles', x),
set: (x) => saveTlFilter('onlyFiles', x),
});

watch([withReplies, onlyFiles], ([withRepliesTo, onlyFilesTo]) => {
Expand All @@ -111,9 +111,9 @@ watch([withReplies, onlyFiles], ([withRepliesTo, onlyFilesTo]) => {
}
});

const withSensitive = computed({
const withSensitive = computed<boolean>({
get: () => defaultStore.reactiveState.tl.value.filter.withSensitive,
set: (x: boolean) => saveTlFilter('withSensitive', x),
set: (x) => saveTlFilter('withSensitive', x),
});

watch(src, () => {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit bac0951

Please sign in to comment.