Files
iptvnator/apps/web/src/app/settings/settings-playlist-summary.utils.ts
T
4gray 1444047a1d refactor: split dashboard rails and settings logic
Split dashboard rails and settings logic into focused helpers/facades while preserving behavior.
2026-06-14 13:34:23 +02:00

46 lines
1.4 KiB
TypeScript

import type { DbOperationEvent } from '@iptvnator/services';
import type { PlaylistMeta } from '@iptvnator/shared/interfaces';
import type { SettingsPlaylistDeleteSummary } from './settings.models';
export function buildSettingsPlaylistDeleteSummary(
items: readonly PlaylistMeta[]
): SettingsPlaylistDeleteSummary {
return {
total: items.length,
m3u: items.filter((item) => !item.serverUrl && !item.macAddress).length,
xtream: items.filter((item) => Boolean(item.serverUrl)).length,
stalker: items.filter((item) => Boolean(item.macAddress)).length,
};
}
export interface RemoveAllProgressLabelInput {
readonly isRemovingAllPlaylists: boolean;
readonly progress: DbOperationEvent | null;
readonly translate: (
key: string,
params?: Record<string, number>
) => string;
}
export function buildRemoveAllProgressLabel({
isRemovingAllPlaylists,
progress,
translate,
}: RemoveAllProgressLabelInput): string | null {
if (!isRemovingAllPlaylists) {
return null;
}
const current = progress?.current;
const total = progress?.total;
if (typeof current === 'number' && typeof total === 'number' && total > 0) {
return translate('SETTINGS.REMOVE_ALL_PROGRESS', {
current,
total,
});
}
return translate('SETTINGS.REMOVE_ALL_IN_PROGRESS');
}