diff --git a/desktop/src/app/AppShell.tsx b/desktop/src/app/AppShell.tsx index 85904fde0e..0bde94cfee 100644 --- a/desktop/src/app/AppShell.tsx +++ b/desktop/src/app/AppShell.tsx @@ -102,6 +102,9 @@ export function AppShell() { const [isChannelManagementOpen, setIsChannelManagementOpen] = React.useState(false); + const [managedChannelId, setManagedChannelId] = React.useState( + null, + ); const [searchFocusRequest, setSearchFocusRequest] = React.useState(0); const [topbarSearchHidden, setTopbarSearchHidden] = React.useState(false); const [topbarSearchLoading, setTopbarSearchLoading] = React.useState(false); @@ -223,6 +226,12 @@ export function AppShell() { : null, [channels, selectedChannelId], ); + const managedChannel = React.useMemo(() => { + const targetChannelId = managedChannelId ?? selectedChannelId; + return targetChannelId + ? (channels.find((channel) => channel.id === targetChannelId) ?? null) + : null; + }, [channels, managedChannelId, selectedChannelId]); const handleThreadReplyDesktopNotification = React.useEffectEvent( (channelId: string, event: RelayEvent) => { @@ -665,7 +674,10 @@ export function AppShell() { markChannelRead, markChannelUnread, openCreateChannel: handleOpenCreateChannel, - openChannelManagement: () => { + openChannelManagement: (channelId?: string) => { + setManagedChannelId( + typeof channelId === "string" ? channelId : null, + ); setIsChannelManagementOpen(true); }, getChannelReadAt, @@ -887,16 +899,22 @@ export function AppShell() { )} { + setIsChannelManagementOpen(open); + if (!open) { + setManagedChannelId(null); + } + }} onDeleteActiveChannel={() => { setIsChannelManagementOpen(false); + setManagedChannelId(null); void goHome({ replace: true }); }} onSelectChannel={(channelId) => { diff --git a/desktop/src/app/AppShellContext.tsx b/desktop/src/app/AppShellContext.tsx index bd27e3019f..584931d5f7 100644 --- a/desktop/src/app/AppShellContext.tsx +++ b/desktop/src/app/AppShellContext.tsx @@ -11,7 +11,7 @@ type AppShellContextValue = { ) => void; markChannelUnread: (channelId: string) => void; openCreateChannel: () => void; - openChannelManagement: () => void; + openChannelManagement: (channelId?: string) => void; // NIP-RS read marker for a channel as a unix-seconds timestamp, or null // when unknown. Backed by the single AppShell-mounted ReadStateManager so // every surface (sidebar, home, badges) projects from the same source. diff --git a/desktop/src/app/routes/index.tsx b/desktop/src/app/routes/index.tsx index 0588fe2ab7..480000bb54 100644 --- a/desktop/src/app/routes/index.tsx +++ b/desktop/src/app/routes/index.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import { createFileRoute } from "@tanstack/react-router"; +import { useAppShell } from "@/app/AppShellContext"; import { useAppNavigation } from "@/app/navigation/useAppNavigation"; import { useChannelsQuery } from "@/features/channels/hooks"; import { HomeScreen } from "@/features/home/ui/HomeScreen"; @@ -16,6 +17,7 @@ export const Route = createFileRoute("/")({ function HomeRouteComponent() { const { goChannel } = useAppNavigation(); + const { openChannelManagement } = useAppShell(); const channelsQuery = useChannelsQuery(); const identityQuery = useIdentityQuery(); const channels = channelsQuery.data ?? []; @@ -65,12 +67,7 @@ function HomeRouteComponent() { { - void goChannel(channelId); - }} - onOpenContext={(channelId, messageId) => { - void goChannel(channelId, { messageId }); - }} + onOpenChannel={openChannelManagement} /> ); } diff --git a/desktop/src/features/home/ui/HomeScreen.tsx b/desktop/src/features/home/ui/HomeScreen.tsx index 2301b21b1f..add42ab460 100644 --- a/desktop/src/features/home/ui/HomeScreen.tsx +++ b/desktop/src/features/home/ui/HomeScreen.tsx @@ -14,14 +14,12 @@ type HomeScreenProps = { availableChannelIds: ReadonlySet; currentPubkey?: string; onOpenChannel: (channelId: string) => void; - onOpenContext: (channelId: string, messageId: string) => void; }; export function HomeScreen({ availableChannelIds, currentPubkey, onOpenChannel, - onOpenContext, }: HomeScreenProps) { const homeFeedQuery = useHomeFeedQuery(); const { threadActivityItems } = useAppShell(); @@ -73,7 +71,6 @@ export function HomeScreen({ feed={augmentedFeed} isLoading={homeFeedQuery.isLoading} onOpenChannel={onOpenChannel} - onOpenContext={onOpenContext} onRefresh={() => { void homeFeedQuery.refetch(); }} diff --git a/desktop/src/features/home/ui/HomeView.tsx b/desktop/src/features/home/ui/HomeView.tsx index e8db2a5daf..4325cb5a1f 100644 --- a/desktop/src/features/home/ui/HomeView.tsx +++ b/desktop/src/features/home/ui/HomeView.tsx @@ -53,7 +53,6 @@ type HomeViewProps = { currentPubkey?: string; availableChannelIds: ReadonlySet; onOpenChannel: (channelId: string) => void; - onOpenContext: (channelId: string, messageId: string) => void; onRefresh: () => void; }; @@ -64,7 +63,6 @@ export function HomeView({ currentPubkey, availableChannelIds, onOpenChannel, - onOpenContext, onRefresh, }: HomeViewProps) { const [homeInboxRef, homeInboxWidthPx] = useElementWidth(); @@ -433,7 +431,6 @@ export function HomeView({ }); }} onOpenChannel={onOpenChannel} - onOpenContext={onOpenContext} onSendReply={async ({ content, mediaTags, diff --git a/desktop/src/features/home/ui/InboxDetailPane.tsx b/desktop/src/features/home/ui/InboxDetailPane.tsx index 8b504744fc..b6953eaf58 100644 --- a/desktop/src/features/home/ui/InboxDetailPane.tsx +++ b/desktop/src/features/home/ui/InboxDetailPane.tsx @@ -60,7 +60,6 @@ type InboxDetailPaneProps = { onBack?: () => void; onDelete: () => void; onOpenChannel: (channelId: string) => void; - onOpenContext?: (channelId: string, messageId: string) => void; onSendReply: (input: { content: string; mediaTags?: string[][]; @@ -94,7 +93,6 @@ export function InboxDetailPane({ onBack, onDelete, onOpenChannel, - onOpenContext, onSendReply, onToggleReaction, onToggleDone, @@ -256,10 +254,10 @@ export function InboxDetailPane({ ) : null}
- {canOpenChannel && contextChannelId && onOpenContext ? ( + {canOpenChannel && contextChannelId ? (