fix(sources): sort by the shown name; start the benchmark's Undo window in its trigger

Local review round 3 (Greptile; Codex was clean):

- Name order compared the stored title, while the rows show a URL-named
  or credential-bearing source by its host: a source stored as
  get.php?username=… sorted by its hidden account details. sortPlaylists
  takes the list's name function, and Sources and the switcher pass
  sourceSortName, the name they display.
- The Xtream delete benchmark clicked Remove while preparing, which starts
  the four-second Undo window; capture setup before the trigger could
  outlast it, so the delete committed on its own before the measurement
  and the close button was gone. Preparation now stops at the open menu,
  and the trigger clicks Remove and then the toast's close button, with
  the trigger time taken right before the commit click as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 5.5 committed 2026-10-13 18:15:09 +02:00
1 parent 123bc170e9
commit 85e6cb3816
10 files changed
+102 -10

No files matched your search

@@ -41,6 +41,31 @@ describe('SortService', () => {
expect(ids).toEqual(['refreshed', 'new', 'old']);
});
it('sorts by name as the list shows it, when told how', () => {
const sources = [
playlist('zed', { title: 'zed' }),
playlist('url', { title: 'get.php?username=zzz&password=x' }),
playlist('mid', { title: 'mid' }),
];
const service = create();
const byTitle = service
.sortPlaylists(sources, { by: SortBy.NAME, order: SortOrder.ASC })
.map((item) => item._id);
expect(byTitle).toEqual(['url', 'mid', 'zed']);
// The URL-named source shows as its host, "abc.test".
const shown = (item: PlaylistMeta) =>
item._id === 'url' ? 'abc.test' : item.title;
const byShownName = service
.sortPlaylists(
sources,
{ by: SortBy.NAME, order: SortOrder.DESC },
shown
)
.map((item) => item._id);
expect(byShownName).toEqual(['zed', 'mid', 'url']);
});
it('sorts by channel count, with no count as zero', () => {
const ids = create()
.sortPlaylists(
+10 -3
View File
@@ -103,9 +103,16 @@ export class SortService {
}
}
/**
* @param nameOf The name a list shows for a source, for Name order: a
* list that shows a source by its host must sort it by its host, not by
* a stored title such as `get.php?username=…`.
*/
sortPlaylists(
playlists: PlaylistMeta[],
options: SortOptions
options: SortOptions,
nameOf: (playlist: PlaylistMeta) => string = (playlist) =>
playlist.title
): PlaylistMeta[] {
const { by, order } = options;
@@ -113,9 +120,9 @@ export class SortService {
let comparison = 0;
if (by === SortBy.NAME) {
comparison = a.title
comparison = nameOf(a)
.toLowerCase()
.localeCompare(b.title.toLowerCase());
.localeCompare(nameOf(b).toLowerCase());
} else if (by === SortBy.DATE_ADDED) {
const dateA = new Date(a.importDate).getTime();
const dateB = new Date(b.importDate).getTime();