Skip to content

Commit

Permalink
fix tl behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Aug 15, 2024
1 parent bccd3dc commit f6fa88d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 17 additions & 1 deletion packages/frontend/src/pages/timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { computed, watch, provide, shallowRef, ref } from 'vue';
import { computed, watch, provide, shallowRef, ref, onActivated, onMounted } from 'vue';
import type { Tab } from '@/components/global/MkPageHeader.tabs.vue';
import MkTimeline from '@/components/MkTimeline.vue';
import MkInfo from '@/components/MkInfo.vue';
Expand Down Expand Up @@ -236,6 +236,22 @@ function closeTutorial(): void {
defaultStore.set('timelineTutorials', before);
}

function switchTlIfNeeded() {
function isNotInList(src: 'hanami' | 'home' | 'local' | 'social' | 'global' | `list:${string}`): src is Exclude<typeof src, `list:${string}`> {
return !src.startsWith('list:');
}
if (isNotInList(src.value) && !availableBasicTimelines().includes(src.value)) {

Check failure on line 243 in packages/frontend/src/pages/timeline.vue

View workflow job for this annotation

GitHub Actions / lint (frontend)

Expected blank line before this statement
src.value = availableBasicTimelines()[0];
}
}

onMounted(() => {
switchTlIfNeeded();
});
onActivated(() => {
switchTlIfNeeded();
});

const headerActions = computed(() => {
const tmp = [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/timelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { $i } from '@/account.js';
import { instance } from '@/instance.js';

export const basicTimelineTypes = [
'hanami',
'home',
'hanami',
'local',
'social',
'global',
Expand Down Expand Up @@ -40,9 +40,9 @@ export function isAvailableBasicTimeline(timeline: BasicTimelineType | undefined
case 'home':
return $i != null;
case 'hanami':
return $i != null && $i.policies.hanamiTlAvailable;
return $i != null && $i.policies.hanamiTlAvailable && $i.isInHanaMode === true;
case 'local':
return ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
return ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable && !$i.isInHanaMode);
case 'social':
return $i != null && $i.policies.ltlAvailable;
case 'global':
Expand Down

0 comments on commit f6fa88d

Please sign in to comment.