fix(torrent): distinguish connected and listed peers

- label live connected peer telemetry separately from listed peer details
- report count mismatches and keep connected values accented
- synchronize bindings, locales, accessibility, and regression coverage
This commit is contained in:
NimBold
2026-08-21 23:04:34 +03:30
parent c385c38556
commit f724616cde
13 changed files with 103 additions and 51 deletions
+19 -1
View File
@@ -5,11 +5,29 @@ import type { PropertiesDiagnosticPhase } from '../propertiesBridge';
export type PropertiesDiagnosticValueState = 'live' | 'loading' | 'stale' | 'error' | 'unavailable';
const isValidDiagnosticCount = (value: number | undefined): value is number =>
typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
export const formatPropertiesDiagnosticCount = (value: number, locale: string): string => {
if (!Number.isSafeInteger(value) || value < 0) return '—';
if (!isValidDiagnosticCount(value)) return '—';
return new Intl.NumberFormat(resolveAppLocale(locale)).format(value);
};
export const hasTorrentPeerCountDifference = (
connectedPeers: number | undefined,
connectedSeeders: number | undefined,
listedPeers: number,
listedSeeders: number,
): boolean => (
isValidDiagnosticCount(connectedPeers)
&& isValidDiagnosticCount(listedPeers)
&& connectedPeers !== listedPeers
) || (
isValidDiagnosticCount(connectedSeeders)
&& isValidDiagnosticCount(listedSeeders)
&& connectedSeeders !== listedSeeders
);
export const hasLiveTorrentPeerWithoutDetails = (
connectedPeers: number | undefined,
detailedPeers: number,