v0.6.2: order sources by most recent message (recency)
- Sidebar sources ordered by Max(created_at) desc instead of alphabetically; "All sources" stays pinned at top (rendered separately). - Live updates move a source to the top when it gets a new message, so the recency order holds without a reload. 152 tests pass; JS re-validated with node --check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ab3e92268a
commit
c1be2face7
4 changed files with 31 additions and 15 deletions
|
|
@ -443,15 +443,17 @@
|
|||
`<span class="source-name">${escapeHtml(name)}</span>` +
|
||||
`<span class="source-count">${count}</span>`;
|
||||
|
||||
// Insert alphabetically among the per-source links (after "All sources").
|
||||
// Newest activity goes to the top of the per-source list (just under
|
||||
// the pinned "All sources"), matching the recency ordering.
|
||||
const list = document.querySelector(".source-list");
|
||||
const others = sourceLinks().filter(
|
||||
(l) => l.querySelector(".source-name")?.textContent.trim() !== "All sources",
|
||||
);
|
||||
const after = others.find(
|
||||
(l) => (l.querySelector(".source-name")?.textContent.trim() || "") > name,
|
||||
);
|
||||
list.insertBefore(link, after || null);
|
||||
const firstSource = list.querySelector(".source-link:not(.all-sources-link)");
|
||||
list.insertBefore(link, firstSource);
|
||||
};
|
||||
|
||||
const moveSourceToTop = (link) => {
|
||||
const list = document.querySelector(".source-list");
|
||||
const firstSource = list.querySelector(".source-link:not(.all-sources-link)");
|
||||
if (firstSource !== link) list.insertBefore(link, firstSource);
|
||||
};
|
||||
|
||||
// From the newly-arrived rows: bump each source's unread count (adding a
|
||||
|
|
@ -466,8 +468,12 @@
|
|||
Object.entries(counts).forEach(([source, n]) => {
|
||||
total += n;
|
||||
const existing = findSourceLink(source);
|
||||
if (existing) bumpSourceBadge(existing, n);
|
||||
else addSourceLink(source, n);
|
||||
if (existing) {
|
||||
bumpSourceBadge(existing, n);
|
||||
moveSourceToTop(existing); // most-recent activity -> top (recency order)
|
||||
} else {
|
||||
addSourceLink(source, n);
|
||||
}
|
||||
});
|
||||
const allLink = findSourceLink("All sources");
|
||||
if (allLink && total) bumpSourceBadge(allLink, total);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue