mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-03 06:27:57 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user