Merge remote-tracking branch 'misskey/master' into feature/misskey-2024.07
This commit is contained in:
commit
cfa9b852df
585 changed files with 23423 additions and 9623 deletions
61
packages/frontend/src/timelines.ts
Normal file
61
packages/frontend/src/timelines.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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',
|
||||
'bubble',
|
||||
'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 'bubble':
|
||||
return 'ph-drop ph-bold ph-lg';
|
||||
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 'bubble':
|
||||
return ($i == null && instance.policies.btlAvailable) || ($i != null && $i.policies.btlAvailable);
|
||||
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';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue