mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-03 14:37:56 +00:00
fix(properties): harden progress and torrent diagnostics
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user