frontend timeline fixes & improvements (#13727)
* fix: withRepliesがオフのときにwithFilesのとぐるをいじれない問題 * fix: type errors in tl-column * fix: deck uiでタイムラインを切り替えた際にTLの設定項目が更新されない * refactor: タイムラインの各種知識を一つのファイルに統合 fix: ウィジェットのタイムライン選択欄に表示できないタイムラインが表示される * docs(changelog): timeline improvements * fix: missing license header * chore: timeline > basic timeline * use BasicTimelineType in deck-store * Update CHANGELOG.md --------- Co-authored-by: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com>
This commit is contained in:
56
packages/frontend/src/timelines.ts
Normal file
56
packages/frontend/src/timelines.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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 && instance.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';
|
||||
}
|
||||
Reference in New Issue
Block a user