👀 format (packages/frontend/src/timelines.ts)
This commit is contained in:
parent
1ba7f5daaa
commit
0b9035c9fc
1 changed files with 45 additions and 30 deletions
|
@ -3,50 +3,63 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { $i } from '@/account.js';
|
import { $i } from "@/account.js";
|
||||||
import { instance } from '@/instance.js';
|
import { instance } from "@/instance.js";
|
||||||
|
|
||||||
export const basicTimelineTypes = [
|
export const basicTimelineTypes = [
|
||||||
'home',
|
"home",
|
||||||
'local',
|
"local",
|
||||||
'social',
|
"social",
|
||||||
'bubble',
|
"bubble",
|
||||||
'global',
|
"global",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type BasicTimelineType = typeof basicTimelineTypes[number];
|
export type BasicTimelineType = (typeof basicTimelineTypes)[number];
|
||||||
|
|
||||||
export function isBasicTimeline(timeline: string): timeline is BasicTimelineType {
|
export function isBasicTimeline(
|
||||||
|
timeline: string,
|
||||||
|
): timeline is BasicTimelineType {
|
||||||
return basicTimelineTypes.includes(timeline as BasicTimelineType);
|
return basicTimelineTypes.includes(timeline as BasicTimelineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function basicTimelineIconClass(timeline: BasicTimelineType): string {
|
export function basicTimelineIconClass(timeline: BasicTimelineType): string {
|
||||||
switch (timeline) {
|
switch (timeline) {
|
||||||
case 'home':
|
case "social":
|
||||||
return 'ti ti-home';
|
return "ti ti-home";
|
||||||
case 'local':
|
case "local":
|
||||||
return 'ti ti-planet';
|
return "ti ti-planet";
|
||||||
case 'social':
|
case "social":
|
||||||
return 'ti ti-universe';
|
return "ti ti-universe";
|
||||||
case 'bubble':
|
case "bubble":
|
||||||
return 'ph-drop ph-bold ph-lg';
|
return "ph-drop ph-bold ph-lg";
|
||||||
case 'global':
|
case "global":
|
||||||
return 'ti ti-whirl';
|
return "ti ti-whirl";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAvailableBasicTimeline(timeline: BasicTimelineType | undefined | null): boolean {
|
export function isAvailableBasicTimeline(
|
||||||
|
timeline: BasicTimelineType | undefined | null,
|
||||||
|
): boolean {
|
||||||
switch (timeline) {
|
switch (timeline) {
|
||||||
case 'home':
|
case "home":
|
||||||
return $i != null;
|
return $i != null;
|
||||||
case 'local':
|
case "local":
|
||||||
return ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
|
return (
|
||||||
case 'social':
|
($i == null && instance.policies.ltlAvailable) ||
|
||||||
|
($i != null && $i.policies.ltlAvailable)
|
||||||
|
);
|
||||||
|
case "social":
|
||||||
return $i != null && $i.policies.ltlAvailable;
|
return $i != null && $i.policies.ltlAvailable;
|
||||||
case 'bubble':
|
case "bubble":
|
||||||
return ($i == null && instance.policies.btlAvailable) || ($i != null && $i.policies.btlAvailable);
|
return (
|
||||||
case 'global':
|
($i == null && instance.policies.btlAvailable) ||
|
||||||
return ($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable);
|
($i != null && $i.policies.btlAvailable)
|
||||||
|
);
|
||||||
|
case "global":
|
||||||
|
return (
|
||||||
|
($i == null && instance.policies.gtlAvailable) ||
|
||||||
|
($i != null && $i.policies.gtlAvailable)
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +69,8 @@ export function availableBasicTimelines(): BasicTimelineType[] {
|
||||||
return basicTimelineTypes.filter(isAvailableBasicTimeline);
|
return basicTimelineTypes.filter(isAvailableBasicTimeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasWithReplies(timeline: BasicTimelineType | undefined | null): boolean {
|
export function hasWithReplies(
|
||||||
return timeline === 'local' || timeline === 'social';
|
timeline: BasicTimelineType | undefined | null,
|
||||||
|
): boolean {
|
||||||
|
return timeline === "local" || timeline === "social";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue