Skip to content

Commit

Permalink
fix(frontend): Misskeyの利用中に使用できるタイムラインの種類が変化した場合、使用できないタイムラインが表示されないよ…
Browse files Browse the repository at this point in the history
…うに (#14412)

* fix(frontend): Misskeyの利用中に使用できるタイムラインの種類が変化した場合、使用できないタイムラインが表示されないように

* Update timeline.vue

* Update timeline.vue
  • Loading branch information
kakkokari-gtyih authored Aug 16, 2024
1 parent 2632204 commit 6db3c50
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions 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, onMounted, onActivated } from 'vue';
import type { Tab } from '@/components/global/MkPageHeader.tabs.vue';
import MkTimeline from '@/components/MkTimeline.vue';
import MkInfo from '@/components/MkInfo.vue';
Expand All @@ -53,15 +53,18 @@ import { deepMerge } from '@/scripts/merge.js';
import { MenuItem } from '@/types/menu.js';
import { miLocalStorage } from '@/local-storage.js';
import { availableBasicTimelines, hasWithReplies, isAvailableBasicTimeline, isBasicTimeline, basicTimelineIconClass } from '@/timelines.js';
import type { BasicTimelineType } from '@/timelines.js';
provide('shouldOmitHeaderTitle', true);
const tlComponent = shallowRef<InstanceType<typeof MkTimeline>>();
const rootEl = shallowRef<HTMLElement>();
type TimelinePageSrc = BasicTimelineType & `list:${string}`;

This comment has been minimized.

Copy link
@anatawa12

anatawa12 Aug 16, 2024

Member

&じゃなくて | なきがする

const queue = ref(0);
const srcWhenNotSignin = ref<'local' | 'global'>(isAvailableBasicTimeline('local') ? 'local' : 'global');
const src = computed<'home' | 'local' | 'social' | 'global' | `list:${string}`>({
const src = computed<TimelinePageSrc>({
get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin.value),
set: (x) => saveSrc(x),
});
Expand Down Expand Up @@ -195,7 +198,7 @@ async function chooseChannel(ev: MouseEvent): Promise<void> {
os.popupMenu(items, ev.currentTarget ?? ev.target);
}
function saveSrc(newSrc: 'home' | 'local' | 'social' | 'global' | `list:${string}`): void {
function saveSrc(newSrc: TimelinePageSrc): void {
const out = deepMerge({ src: newSrc }, defaultStore.state.tl);
if (newSrc.startsWith('userList:')) {
Expand Down Expand Up @@ -236,6 +239,19 @@ function closeTutorial(): void {
defaultStore.set('timelineTutorials', before);
}
function switchTlIfNeeded() {
if (isBasicTimeline(src.value) && !availableBasicTimelines().includes(src.value)) {
src.value = availableBasicTimelines()[0];
}
}
onMounted(() => {
switchTlIfNeeded();
});
onActivated(() => {
switchTlIfNeeded();
});
const headerActions = computed(() => {
const tmp = [
{
Expand Down

0 comments on commit 6db3c50

Please sign in to comment.