sidebar: sort channels by last opened (localStorage)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 21:23:16 +02:00
parent 1830b520a6
commit 36561941b4

View File

@@ -108,11 +108,21 @@ export default function App() {
const messagesById = new Map(messages.map((m) => [m.id, m]));
const activeChannel = channels.find((c) => c.id === activeChannelId);
// Sort channels by last opened (stored in localStorage)
function getLastOpened(channelId: string): number {
return Number(localStorage.getItem(`colony_last_opened_${channelId}`)) || 0;
}
function markOpened(channelId: string) {
localStorage.setItem(`colony_last_opened_${channelId}`, String(Date.now()));
}
const sortedChannels = [...channels].sort((a, b) => getLastOpened(b.id) - getLastOpened(a.id));
const sidebar = (
<ChannelSidebar
channels={channels}
channels={sortedChannels}
activeId={activeChannelId}
onSelect={(id) => {
markOpened(id);
setActiveChannelId(id);
setSheetOpen(false);
}}