yumechi-no-kuni/packages/frontend/src/timelines.ts
taichan d6ba12e24c
Fix(frontend): LTL無効時にヘッダーにSTLが表示されてしまう & デフォルト、クラシックでリストが消えている (#14337)
* Fix condition of STL available

* Fix: condition of stl

* Listがタイムラインのヘッダーから消えている
2024-07-31 18:10:36 +09:00

56 lines
1.5 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { $i } from '@/account.js';
import { instance } from '@/instance.js';
export const basicTimelineTypes = [
'home',
'local',
'social',
'global',
] as const;
export type BasicTimelineType = typeof basicTimelineTypes[number];
export function isBasicTimeline(timeline: string): timeline is BasicTimelineType {
return basicTimelineTypes.includes(timeline as BasicTimelineType);
}
export function basicTimelineIconClass(timeline: BasicTimelineType): string {
switch (timeline) {
case 'home':
return 'ti ti-home';
case 'local':
return 'ti ti-planet';
case 'social':
return 'ti ti-universe';
case 'global':
return 'ti ti-whirl';
}
}
export function isAvailableBasicTimeline(timeline: BasicTimelineType | undefined | null): boolean {
switch (timeline) {
case 'home':
return $i != null;
case 'local':
return ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
case 'social':
return $i != null && $i.policies.ltlAvailable;
case 'global':
return ($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable);
default:
return false;
}
}
export function availableBasicTimelines(): BasicTimelineType[] {
return basicTimelineTypes.filter(isAvailableBasicTimeline);
}
export function hasWithReplies(timeline: BasicTimelineType | undefined | null): boolean {
return timeline === 'local' || timeline === 'social';
}