fix(properties): harden progress and torrent diagnostics

This commit is contained in:
NimBold
2026-08-07 13:32:52 +03:30
parent e402603edb
commit facb7b3300
16 changed files with 291 additions and 45 deletions
+11
View File
@@ -1,9 +1,20 @@
import type { TorrentPeerDiagnostics } from '../bindings/TorrentPeerDiagnostics';
import type { TorrentAvailabilitySnapshot } from '../bindings/TorrentAvailabilitySnapshot';
import { resolveAppLocale } from '../i18n/locales';
import type { PropertiesDiagnosticPhase } from '../propertiesBridge';
export type PropertiesDiagnosticValueState = 'live' | 'loading' | 'stale' | 'error' | 'unavailable';
export const formatPropertiesDiagnosticCount = (value: number, locale: string): string => {
if (!Number.isSafeInteger(value) || value < 0) return '—';
return new Intl.NumberFormat(resolveAppLocale(locale)).format(value);
};
export const formatPropertiesAvailability = (availability: number, locale: string): string => {
if (!Number.isFinite(availability) || availability < 0) return '—';
return new Intl.NumberFormat(resolveAppLocale(locale), { maximumFractionDigits: 2 }).format(availability);
};
const getPropertiesDiagnosticValueState = (
hasValue: boolean,
diagnosticsLoading: boolean,