sort detailed profiles

This commit is contained in:
Julian Freeman
2026-04-16 17:53:18 -04:00
parent 65b9401726
commit 761e4f3186
3 changed files with 43 additions and 2 deletions

View File

@@ -3,6 +3,9 @@ import type {
BookmarkSummary,
ExtensionSortKey,
ExtensionSummary,
AssociatedProfileSortKey,
AssociatedProfileSummary,
BookmarkAssociatedProfileSummary,
ProfileSortKey,
ProfileSummary,
} from "../types/browser";
@@ -73,6 +76,19 @@ export function sortBookmarks(items: BookmarkSummary[], sortKey: BookmarkSortKey
});
}
export function sortAssociatedProfiles(
items: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[],
sortKey: AssociatedProfileSortKey,
) {
const profiles = [...items];
return profiles.sort((left, right) => {
if (sortKey === "name") {
return compareText(left.name, right.name) || compareProfileId(left.id, right.id);
}
return compareProfileId(left.id, right.id) || compareText(left.name, right.name);
});
}
function profileSortKeyValue(profileId: string) {
if (profileId === "Default") {
return { group: 0, number: 0, text: profileId };