diff --git a/desktop/src/app/AppShell.tsx b/desktop/src/app/AppShell.tsx index 5b65584e8c..c79e243762 100644 --- a/desktop/src/app/AppShell.tsx +++ b/desktop/src/app/AppShell.tsx @@ -865,7 +865,6 @@ export function AppShell() { onCreateChannel={handleCreateChannel} onCreateForum={handleCreateForum} onHideDm={handleHideDm} - onMarkAllChannelsRead={markAllChannelsRead} onMarkChannelRead={markChannelRead} onMarkChannelUnread={markChannelUnread} onBrowseChannels={handleOpenBrowseChannels} diff --git a/desktop/src/features/sidebar/ui/AppSidebar.tsx b/desktop/src/features/sidebar/ui/AppSidebar.tsx index cf0e65bc7a..130e44fa30 100644 --- a/desktop/src/features/sidebar/ui/AppSidebar.tsx +++ b/desktop/src/features/sidebar/ui/AppSidebar.tsx @@ -130,7 +130,6 @@ type AppSidebarProps = { channelId: string, lastMessageAt: string | null | undefined, ) => void; - onMarkAllChannelsRead: () => void; onBrowseChannels?: (onCreated?: (channelId: string) => void) => void; onOpenDm: (input: { pubkeys: string[] }) => Promise; onUpdateCommunity: ( @@ -200,7 +199,6 @@ export function AppSidebar({ onHideDm, onMarkChannelUnread, onMarkChannelRead, - onMarkAllChannelsRead, onBrowseChannels, onOpenDm, onUpdateCommunity, @@ -481,6 +479,15 @@ export function AppSidebar({ ), [directMessages, dmChannelLabels, sortModeFor], ); + const unassignedChannelsHaveUnread = sectionBuckets.unassigned.some( + (channel) => unreadChannelIds.has(channel.id), + ); + const forumsHaveUnread = forumChannels.some((channel) => + unreadChannelIds.has(channel.id), + ); + const directMessagesHaveUnread = sortedDirectMessages.some((channel) => + unreadChannelIds.has(channel.id), + ); const sidebarLoadingShape = useSidebarLoadingShape({ activeCommunityId: activeCommunity?.id, currentPubkey, @@ -709,7 +716,7 @@ export function AppSidebar({ ))} 0} + hasUnread={unassignedChannelsHaveUnread} isCollapsed={collapsedGroups.channels} isActiveChannel={selectedView === "channel"} activeWorkingByChannelId={activeWorkingByChannelId} @@ -723,7 +730,11 @@ export function AppSidebar({ quickCreateLabel="Add channel" onQuickCreateClick={onBrowseChannels} showQuickCreate - onMarkAllRead={onMarkAllChannelsRead} + onMarkAllRead={() => { + for (const channel of sectionBuckets.unassigned) { + onMarkChannelRead(channel.id, channel.lastMessageAt); + } + }} onMarkChannelRead={onMarkChannelRead} onMarkChannelUnread={onMarkChannelUnread} onSelectChannel={onSelectChannel} @@ -749,7 +760,7 @@ export function AppSidebar({ 0} + hasUnread={forumsHaveUnread} isCollapsed={collapsedGroups.forums} isActiveChannel={selectedView === "channel"} activeWorkingByChannelId={activeWorkingByChannelId} @@ -761,7 +772,11 @@ export function AppSidebar({ actionsTestId="section-actions-forums" listTestId="forum-list" onCreateClick={() => openCreateDialog("forum")} - onMarkAllRead={onMarkAllChannelsRead} + onMarkAllRead={() => { + for (const channel of forumChannels) { + onMarkChannelRead(channel.id, channel.lastMessageAt); + } + }} onMarkChannelRead={onMarkChannelRead} onMarkChannelUnread={onMarkChannelUnread} onSelectChannel={onSelectChannel} @@ -787,6 +802,15 @@ export function AppSidebar({ sectionLabel="direct messages" testId="section-actions-dms" onOpenChange={setDmActionsMenuOpen} + hasUnread={directMessagesHaveUnread} + onMarkAllRead={() => { + for (const channel of sortedDirectMessages) { + onMarkChannelRead( + channel.id, + channel.lastMessageAt, + ); + } + }} onNewMessage={onNewMessage} sortMode={sortModeFor("dms")} onSortModeChange={(mode) => @@ -796,6 +820,7 @@ export function AppSidebar({ } dmParticipantsByChannelId={dmParticipantsByChannelId} + hasUnread={directMessagesHaveUnread} isCollapsed={collapsedGroups.directMessages} isActiveChannel={selectedView === "channel"} activeWorkingByChannelId={activeWorkingByChannelId} diff --git a/desktop/src/features/sidebar/ui/CustomChannelSection.tsx b/desktop/src/features/sidebar/ui/CustomChannelSection.tsx index 2b266e887e..470e1c142a 100644 --- a/desktop/src/features/sidebar/ui/CustomChannelSection.tsx +++ b/desktop/src/features/sidebar/ui/CustomChannelSection.tsx @@ -288,8 +288,20 @@ export function SectionActionsMenu({ ); } +function SectionUnreadIndicator({ testId }: { testId: string }) { + return ( +