diff --git a/ui/colony/src/App.tsx b/ui/colony/src/App.tsx index b2b3214..25b6c7e 100644 --- a/ui/colony/src/App.tsx +++ b/ui/colony/src/App.tsx @@ -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 = ( { + markOpened(id); setActiveChannelId(id); setSheetOpen(false); }}