refactor: track lengths and file sizes come from the shared formatters on Missing files, Duplicates, a want's Releases and the app download; an hour-long track reads 1:01:05, not 61:05 (M505 #5639 #5640)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 16:14:01 -04:00
co-authored by Claude Opus 5.5
parent 9e7d50b38e
commit 622f248ea2
7 changed files with 35 additions and 32 deletions
@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import { Download, Smartphone } from 'lucide-svelte';
import { api } from '#lib/api/client.js';
import { formatBytes } from '#lib/utils/bytes.js';
import SettingsGroup from '#lib/components/settings/SettingsGroup.svelte';
import SettingRow from '#lib/components/settings/SettingRow.svelte';
@@ -20,11 +21,6 @@
let info = $state<Info | null>(null);
function formatSize(bytes: number): string {
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)} KB`;
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
}
onMount(async () => {
try {
const body = await api.get<Partial<WireInfo>>('/api/client/version');
@@ -44,7 +40,7 @@
<SettingsGroup title="Android app">
<SettingRow
label="Minstrel for Android"
hint="{info.version}{info.sizeBytes > 0 ? ` · ${formatSize(info.sizeBytes)}` : ''} · sign in with this account"
hint="{info.version}{info.sizeBytes > 0 ? ` · ${formatBytes(info.sizeBytes)}` : ''} · sign in with this account"
>
<Smartphone size={18} strokeWidth={1.5} class="text-text-secondary" aria-hidden="true" />
<a
+3 -7
View File
@@ -10,6 +10,7 @@
import { errMessage } from '#lib/api/errors.js';
import { pushToast } from '#lib/stores/toast.svelte.js';
import { relativeTime } from '#lib/utils/relativeTime.js';
import { formatBytes } from '#lib/utils/bytes.js';
import type { Candidate, CandidateVerdict, GrabResult } from '#lib/api/types.js';
// Every release a want's last search found (M502 #5521), with the verdict
@@ -41,14 +42,9 @@
blocked: 'bg-surface-hover text-text-muted'
};
function size(bytes: number): string {
if (bytes <= 0) return '';
if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;
return `${Math.max(1, Math.round(bytes / 1e6))} MB`;
}
function meta(c: Candidate): string {
const parts = [c.format || 'format not stated', size(c.size_bytes)];
// An indexer that states no size sends 0.
const parts = [c.format || 'format not stated', c.size_bytes > 0 ? formatBytes(c.size_bytes) : ''];
parts.push(c.seeders === 1 ? '1 seeder' : `${c.seeders} seeders`);
if (c.indexer) parts.push(c.folded_from.length ? `${c.indexer} +${c.folded_from.length}` : c.indexer);
return parts.filter(Boolean).join(' · ');