mizzkey/packages/frontend/src/timeline-header.ts

74 lines
1.6 KiB
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { reactive } from 'vue';
import { i18n } from '@/i18n.js';
import { userListsCache } from '@/cache.js';
2024-06-11 12:19:42 +02:00
import { isLocalTimelineAvailable, isGlobalTimelineAvailable } from '@/scripts/get-timeline-available.js';
export type TimelineHeaderItem =
'home' |
'local' |
'social' |
'global' |
'lists' |
'antennas' |
'channels' |
`list:${string}`
type TimelineHeaderItemsDef = {
title: string;
icon: string;
iconOnly?: boolean; // わからん
}
const lists = await userListsCache.fetch();
2024-06-11 12:19:42 +02:00
export const timelineHeaderItemDef = reactive<Partial<Record<TimelineHeaderItem, TimelineHeaderItemsDef>>>({
home: {
title: i18n.ts._timelines.home,
icon: 'ti ti-home',
2024-06-11 12:19:42 +02:00
iconOnly: true,
},
...(isLocalTimelineAvailable ? {
local: {
title: i18n.ts._timelines.local,
icon: 'ti ti-planet',
iconOnly: true,
},
social: {
title: i18n.ts._timelines.social,
icon: 'ti ti-universe',
iconOnly: true,
} } : {}),
...(isGlobalTimelineAvailable ? { global: {
title: i18n.ts._timelines.global,
icon: 'ti ti-whirl',
iconOnly: true,
} } : {}),
lists: {
icon: 'ti ti-list',
title: i18n.ts.lists,
iconOnly: true,
},
antennas: {
icon: 'ti ti-antenna',
title: i18n.ts.antennas,
iconOnly: true,
},
channels: {
icon: 'ti ti-device-tv',
title: i18n.ts.channel,
iconOnly: true,
},
...lists.reduce((acc, l) => {
acc['list:' + l.id] = {
title: i18n.ts.lists + ':' + l.name,
icon: 'ti ti-star',
iconOnly: true,
};
return acc;
}, {}),
});