From 0e49dd6066f73611a532755c06f83c6073e63fea Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 9 Aug 2022 16:12:20 -0700 Subject: [PATCH] fix: :lock: Remove timeline source if not logged in and guest tl isn't enabled --- packages/client/src/pages/timeline.vue | 6 +++++- packages/client/src/router.ts | 19 ++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/client/src/pages/timeline.vue b/packages/client/src/pages/timeline.vue index 21fc8080f..c6a9a9c1b 100644 --- a/packages/client/src/pages/timeline.vue +++ b/packages/client/src/pages/timeline.vue @@ -38,6 +38,7 @@ const XTutorial = defineAsyncComponent(() => import('./timeline.tutorial.vue')); const isLocalTimelineAvailable = !instance.disableLocalTimeline || ($i != null && ($i.isModerator || $i.isAdmin)); const isRecommendedTimelineAvailable = !instance.disableRecommendedTimeline || ($i != null && ($i.isModerator || $i.isAdmin)); const isGlobalTimelineAvailable = !instance.disableGlobalTimeline || ($i != null && ($i.isModerator || $i.isAdmin)); +const enableGuestTimeline = instance.enableGuestTimeline; const keymap = { 't': focus, }; @@ -47,7 +48,10 @@ const rootEl = $ref(); let queue = $ref(0); let srcWhenNotSignin = $ref(isLocalTimelineAvailable ? 'local' : 'global'); -const src = $computed({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin), set: (x) => saveSrc(x) }); +let src = $computed({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin), set: (x) => saveSrc(x) }); +if (!enableGuestTimeline) { + src = $computed({}); +} watch ($$(src), () => queue = 0); diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index 4f1c9dc89..2112c7aeb 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -6,18 +6,15 @@ import MkError from '@/pages/_error_.vue'; import { api } from '@/os'; import { ui } from '@/config'; -const meta = api('meta', { - detail: false -}).then((meta) => { - console.log(meta); - console.log(meta[0]); - console.log(meta[1]); - console.log(meta[0][0]); - // const guestTimeline = meta.enableGuestTimeline; - // console.log(guestTimeline); -}); +function getGuestTimelineStatus() { + api('meta', { + detail: false + }).then((meta) => { + return meta.enableGuestTimeline; + }); +} -const guestTimeline = true; +const guestTimeline = getGuestTimelineStatus(); const page = (loader: AsyncComponentLoader) => defineAsyncComponent({ loader: loader,