diff --git a/web/src/lib/playlists/shelf.test.ts b/web/src/lib/playlists/shelf.test.ts index 98d0d9d2..a0357c11 100644 --- a/web/src/lib/playlists/shelf.test.ts +++ b/web/src/lib/playlists/shelf.test.ts @@ -88,7 +88,7 @@ describe('refreshedLabel', () => { test('yesterday and older', () => { const now = new Date('2026-11-23T12:00:00'); expect(refreshedLabel('2026-11-22T12:00:00', now)).toBe('Refreshed yesterday'); - expect(refreshedLabel('2026-11-20T12:00:00', now)).toBe('Refreshed 4 days ago'); + expect(refreshedLabel('2026-11-20T12:00:00', now)).toBe('Refreshed 3 days ago'); }); }); diff --git a/web/src/lib/playlists/shelf.ts b/web/src/lib/playlists/shelf.ts index bb30f5dd..55325c41 100644 --- a/web/src/lib/playlists/shelf.ts +++ b/web/src/lib/playlists/shelf.ts @@ -1,6 +1,7 @@ // What a home shelf of playlist tiles shows: which album covers each tile // gets, and the one line of facts the shelf's tiles share. import type { Playlist } from '#lib/api/types.js'; +import { plural } from '#lib/utils/plural.js'; // Each tile takes the first of its playlist's cover albums that no tile // before it on the shelf already shows, so a shelf never repeats a cover @@ -48,11 +49,11 @@ export function shelfMeta(playlists: Playlist[], now: Date = new Date()): string const lo = counts[0]; const hi = counts[counts.length - 1]; if (lo === hi) { - parts.push(`${lo} ${lo === 1 ? 'song' : 'songs'} each`); + parts.push(`${plural(lo, 'song', 'songs')} each`); } else if (hi - lo <= hi * 0.1) { // Close enough to read as one size: round the middle to a friendly 5. const mid = counts[Math.floor(counts.length / 2)]; - parts.push(`about ${Math.max(5, Math.round(mid / 5) * 5)} songs each`); + parts.push(`about ${plural(Math.max(5, Math.round(mid / 5) * 5), 'song', 'songs')} each`); } const labels = new Set(mixes.map((p) => refreshedLabel(p.created_at, now)));