|
1 | | -import { ChevronLeft, ChevronRight } from "lucide-react"; |
2 | 1 | import * as React from "react"; |
3 | 2 | import { getCurrentWindow } from "@tauri-apps/api/window"; |
4 | 3 | import { useQueryClient } from "@tanstack/react-query"; |
|
9 | 8 | AppShellOverlays, |
10 | 9 | type BrowseDialogType, |
11 | 10 | } from "@/app/AppShellOverlays"; |
| 11 | +import { AppTopChrome } from "@/app/AppTopChrome"; |
12 | 12 | import { useAppNavigation } from "@/app/navigation/useAppNavigation"; |
13 | 13 | import { useBackForwardControls } from "@/app/navigation/useBackForwardControls"; |
14 | 14 | import { useMarkAsReadShortcuts } from "@/app/useMarkAsReadShortcuts"; |
@@ -62,12 +62,7 @@ import type { Channel, RelayEvent, SearchHit } from "@/shared/api/types"; |
62 | 62 | import { ChannelNavigationProvider } from "@/shared/context/ChannelNavigationContext"; |
63 | 63 | import { hasPrimaryShortcutModifier } from "@/shared/lib/platform"; |
64 | 64 | import { useMessageDeepLinks } from "@/shared/useMessageDeepLinks"; |
65 | | -import { Button } from "@/shared/ui/button"; |
66 | | -import { |
67 | | - SidebarInset, |
68 | | - SidebarProvider, |
69 | | - SidebarTrigger, |
70 | | -} from "@/shared/ui/sidebar"; |
| 65 | +import { SidebarInset, SidebarProvider } from "@/shared/ui/sidebar"; |
71 | 66 |
|
72 | 67 | type AppView = |
73 | 68 | | "home" |
@@ -174,7 +169,7 @@ export function AppShell() { |
174 | 169 |
|
175 | 170 | const [isChannelManagementOpen, setIsChannelManagementOpen] = |
176 | 171 | React.useState(false); |
177 | | - const [isSearchOpen, setIsSearchOpen] = React.useState(false); |
| 172 | + const [searchFocusRequest, setSearchFocusRequest] = React.useState(0); |
178 | 173 | const [browseDialogType, setBrowseDialogType] = |
179 | 174 | React.useState<BrowseDialogType>(null); |
180 | 175 | const [isNewDmOpen, setIsNewDmOpen] = React.useState(false); |
@@ -365,7 +360,7 @@ export function AppShell() { |
365 | 360 | void refetchChannels(); |
366 | 361 | }, [refetchChannels]); |
367 | 362 | const handleOpenSearch = React.useCallback(() => { |
368 | | - setIsSearchOpen(true); |
| 363 | + setSearchFocusRequest((request) => request + 1); |
369 | 364 | void refetchChannels(); |
370 | 365 | }, [refetchChannels]); |
371 | 366 |
|
@@ -400,7 +395,6 @@ export function AppShell() { |
400 | 395 |
|
401 | 396 | const handleOpenSettings = React.useCallback( |
402 | 397 | (section: SettingsSection = DEFAULT_SETTINGS_SECTION) => { |
403 | | - setIsSearchOpen(false); |
404 | 398 | setIsChannelManagementOpen(false); |
405 | 399 | setSettingsSection(section); |
406 | 400 | setSettingsOpen(true); |
@@ -659,36 +653,19 @@ export function AppShell() { |
659 | 653 | <HuddleProvider> |
660 | 654 | <div className="flex h-dvh flex-col overflow-hidden overscroll-none"> |
661 | 655 | <SidebarProvider className="min-h-0 flex-1 overflow-hidden"> |
662 | | - <div |
663 | | - aria-hidden="true" |
664 | | - className="fixed inset-x-0 top-0 z-20 h-10 cursor-default select-none" |
665 | | - data-tauri-drag-region |
| 656 | + <AppTopChrome |
| 657 | + canGoBack={canGoBack} |
| 658 | + canGoForward={canGoForward} |
| 659 | + channels={channels} |
| 660 | + currentPubkey={identityQuery.data?.pubkey} |
| 661 | + onGoBack={goBack} |
| 662 | + onGoForward={goForward} |
| 663 | + onOpenChannel={(channelId) => { |
| 664 | + void goChannel(channelId); |
| 665 | + }} |
| 666 | + onOpenResult={handleOpenSearchResult} |
| 667 | + searchFocusRequest={searchFocusRequest} |
666 | 668 | /> |
667 | | - <div className="fixed left-[80px] top-[9px] z-50 flex items-center gap-0.5"> |
668 | | - <SidebarTrigger className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground" /> |
669 | | - <Button |
670 | | - aria-label="Go back" |
671 | | - className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground" |
672 | | - data-testid="global-back" |
673 | | - disabled={!canGoBack} |
674 | | - onClick={goBack} |
675 | | - size="icon" |
676 | | - variant="ghost" |
677 | | - > |
678 | | - <ChevronLeft className="h-3 w-3" /> |
679 | | - </Button> |
680 | | - <Button |
681 | | - aria-label="Go forward" |
682 | | - className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground" |
683 | | - data-testid="global-forward" |
684 | | - disabled={!canGoForward} |
685 | | - onClick={goForward} |
686 | | - size="icon" |
687 | | - variant="ghost" |
688 | | - > |
689 | | - <ChevronRight className="h-3 w-3" /> |
690 | | - </Button> |
691 | | - </div> |
692 | 669 | <AppSidebar |
693 | 670 | activeWorkspace={workspacesHook.activeWorkspace} |
694 | 671 | channels={sidebarChannels} |
@@ -770,7 +747,6 @@ export function AppShell() { |
770 | 747 | }); |
771 | 748 | await goChannel(directMessage.id); |
772 | 749 | }} |
773 | | - onOpenSearch={handleOpenSearch} |
774 | 750 | onSelectAgents={() => { |
775 | 751 | void goAgents(); |
776 | 752 | }} |
@@ -821,16 +797,13 @@ export function AppShell() { |
821 | 797 | channels={channels} |
822 | 798 | currentPubkey={identityQuery.data?.pubkey} |
823 | 799 | isChannelManagementOpen={isChannelManagementOpen} |
824 | | - isSearchOpen={isSearchOpen} |
825 | 800 | onBrowseChannelJoin={handleBrowseChannelJoin} |
826 | 801 | onBrowseDialogOpenChange={handleBrowseDialogOpenChange} |
827 | 802 | onChannelManagementOpenChange={setIsChannelManagementOpen} |
828 | 803 | onDeleteActiveChannel={() => { |
829 | 804 | setIsChannelManagementOpen(false); |
830 | 805 | void goHome({ replace: true }); |
831 | 806 | }} |
832 | | - onOpenSearchResult={handleOpenSearchResult} |
833 | | - onSearchOpenChange={setIsSearchOpen} |
834 | 807 | onSelectChannel={(channelId) => { |
835 | 808 | void goChannel(channelId); |
836 | 809 | }} |
|
0 commit comments