Podcasts sort by name with a leading "The" set aside (#481)

The feed list, the Podcasts shelf and the playlist dialog took the
server's order, which is by id, a slug of the title, so The Rest Is
Science was under T; the Directory sorted by title the same way. One
helper, nameOrder, now orders names with a leading "The" aside, case and
accents aside and numbers by value. renderFeeds sorts S.feeds with it, so
a feed a live update adds or renames takes its place as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkrVAJFkEgz9cXG3jG1Zy
This commit is contained in:
2026-11-19 08:41:24 -05:00
parent aba6bd52a7
commit 8512851e4b
5 changed files with 17 additions and 2 deletions

View File

@@ -108,7 +108,7 @@ let dirShow: string|null=null;
// Apple's or one an admin typed, neither of which starts with a colon.
const EVERY=':every', OTHER=':other';
const NAME=(p: {title: string|null, id: string})=>(p.title||p.id);
const byName=(a: DirFeed,b: DirFeed)=>NAME(a).localeCompare(NAME(b),undefined,{sensitivity:'base',numeric:true});
const byName=(a: DirFeed,b: DirFeed)=>nameOrder(NAME(a),NAME(b));
const bySubs=(a: DirFeed,b: DirFeed)=>b.subscribers-a.subscribers||byName(a,b);
/// The grid's orders. It opens A to Z, as the server sends it.
const DIR_SORTS: Record<string,[string,(a: DirFeed,b: DirFeed)=>number]>={

View File

@@ -25,7 +25,7 @@ async function loadFeeds(keepSel?: boolean){
}
}
// An OPML can hold dozens of feeds; the ones with something new go first. sort is stable, so the
// server's alphabetical order still holds within each half.
// list's order by name (renderFeeds) still holds within each half.
const unreadFirst=(a: Feed,b: Feed)=>Number(b.unread>0)-Number(a.unread>0);
// The original's source list opened with these, above the feeds. They are places, not feeds:
// an id starting with ':' can never be a feed's, since feed ids are slugs.
@@ -95,6 +95,9 @@ function spinEnd(done?: {only: string|null, forced: boolean}){
}
function renderFeeds(){
// By name, not the server's order, which is by id: a slug of the title, so The Rest Is Science
// was under T (#481). Here, so a feed a live update adds or renames takes its place too.
S.feeds.sort((a,b)=>nameOrder(a.title||a.id,b.title||b.id));
const q=$<HTMLInputElement>('#feedFilter').value.trim().toLowerCase();
const list=$('#feedlist'); const top=list.scrollTop;
// Every row is replaced, so put the keyboard back on the row, or the triangle, it was on.

View File

@@ -4,6 +4,10 @@
const $ = <T extends HTMLElement = HTMLElement>(s: string, r: ParentNode = document): T => r.querySelector<T>(s)!;
const $$ = <T extends HTMLElement = HTMLElement>(s: string, r: ParentNode = document): T[] => [...r.querySelectorAll<T>(s)];
/// What went wrong, from whatever a catch caught: the page throws Errors, but a catch cannot know.
/// Two names in the order a shelf files them: a leading "The" aside, so The Rest Is Science is under
/// R (#481), with case and accents aside and 2 before 10.
const nameOrder = (a: string, b: string): number =>
a.replace(/^the\s+/i,'').localeCompare(b.replace(/^the\s+/i,''),undefined,{sensitivity:'base',numeric:true});
const why = (e: unknown): string => e instanceof Error ? e.message : String(e);
/// A row that opens a feed, a place or a show (the feed list, the Directory): a link to a screen
/// reader, named by what it shows, the open one marked current. Not a button, whose contents a