@@ -4,14 +4,12 @@ import { Outlet, useLocation } from "@tanstack/react-router";
44
55import { deriveShellRoute } from "@/app/AppShell.helpers" ;
66import { AppShellProvider } from "@/app/AppShellContext" ;
7- import {
8- AppShellOverlays ,
9- type BrowseDialogType ,
10- } from "@/app/AppShellOverlays" ;
7+ import { AppShellOverlays } from "@/app/AppShellOverlays" ;
118import { AppTopChrome } from "@/app/AppTopChrome" ;
129import { useAppNavigation } from "@/app/navigation/useAppNavigation" ;
1310import { useBackForwardControls } from "@/app/navigation/useBackForwardControls" ;
1411import { useLiveHomeFeedActions } from "@/app/useLiveHomeFeedActions" ;
12+ import { useChannelBrowserDialog } from "@/app/useChannelBrowserDialog" ;
1513import { useMarkAsReadShortcuts } from "@/app/useMarkAsReadShortcuts" ;
1614import { useSettingsShortcuts } from "@/app/useSettingsShortcuts" ;
1715import { useAppShellDesktopNotifications } from "@/app/useAppShellDesktopNotifications" ;
@@ -110,8 +108,6 @@ export function AppShell() {
110108 null ,
111109 ) ;
112110 const [ searchFocusRequest , setSearchFocusRequest ] = React . useState ( 0 ) ;
113- const [ browseDialogType , setBrowseDialogType ] =
114- React . useState < BrowseDialogType > ( null ) ;
115111 const [ isCreateChannelOpen , setIsCreateChannelOpen ] = React . useState ( false ) ;
116112 const [ isSendFeedbackOpen , setIsSendFeedbackOpen ] = React . useState ( false ) ;
117113 const [ isHuddleDrawerOpen , setIsHuddleDrawerOpen ] = React . useState ( false ) ;
@@ -415,27 +411,22 @@ export function AppShell() {
415411 [ unfollowThread , muteThread ] ,
416412 ) ;
417413
418- const createChannelMutation = useCreateChannelMutation ( ) ;
419- const createForumMutation = useCreateChannelMutation ( ) ;
414+ const createChannelMutation = useCreateChannelMutation ( ) ,
415+ createForumMutation = useCreateChannelMutation ( ) ;
420416 const { applyCanvas, applyAgents } = useApplyTemplate ( ) ;
421-
422417 const openDmMutation = useOpenDmMutation ( ) ;
423418 const hideDmMutation = useHideDmMutation ( ) ;
424- const handleOpenBrowseChannels = React . useCallback ( ( ) => {
425- setBrowseDialogType ( "stream" ) ;
426- void refetchChannels ( ) ;
427- } , [ refetchChannels ] ) ;
419+ const {
420+ browseDialogType,
421+ openBrowseChannels : handleOpenBrowseChannels ,
422+ onBrowseDialogOpenChange : handleBrowseDialogOpenChange ,
423+ getCreateSuccess,
424+ } = useChannelBrowserDialog ( ( ) => void refetchChannels ( ) ) ;
428425 const handleOpenSearch = React . useCallback ( ( ) => {
429426 setSearchFocusRequest ( ( request ) => request + 1 ) ;
430427 void refetchChannels ( ) ;
431428 } , [ refetchChannels ] ) ;
432429
433- const handleBrowseDialogOpenChange = React . useCallback ( ( open : boolean ) => {
434- if ( ! open ) {
435- setBrowseDialogType ( null ) ;
436- }
437- } , [ ] ) ;
438-
439430 const handleBrowseChannelJoin = React . useCallback (
440431 async ( channelId : string ) => {
441432 await joinChannel ( channelId ) ;
@@ -445,19 +436,22 @@ export function AppShell() {
445436 ) ;
446437
447438 const handleCreateChannel = React . useCallback (
448- async ( {
449- description,
450- name,
451- visibility,
452- ttlSeconds,
453- templateId,
454- } : {
455- name : string ;
456- description ?: string ;
457- visibility : ChannelVisibility ;
458- ttlSeconds ?: number ;
459- templateId ?: string ;
460- } ) => {
439+ async (
440+ {
441+ description,
442+ name,
443+ visibility,
444+ ttlSeconds,
445+ templateId,
446+ } : {
447+ name : string ;
448+ description ?: string ;
449+ visibility : ChannelVisibility ;
450+ ttlSeconds ?: number ;
451+ templateId ?: string ;
452+ } ,
453+ onCreated ?: ( channelId : string ) => void ,
454+ ) => {
461455 const createdChannel = await createChannelMutation . mutateAsync ( {
462456 name,
463457 description,
@@ -468,6 +462,7 @@ export function AppShell() {
468462
469463 await applyCanvas ( templateId , createdChannel . id , name ) ;
470464 await goChannel ( createdChannel . id ) ;
465+ onCreated ?.( createdChannel . id ) ;
471466 void applyAgents ( templateId , createdChannel . id ) ;
472467 } ,
473468 [ applyAgents , applyCanvas , createChannelMutation , goChannel ] ,
@@ -515,10 +510,15 @@ export function AppShell() {
515510 if ( browseDialogType === "forum" ) {
516511 await handleCreateForum ( input ) ;
517512 } else {
518- await handleCreateChannel ( input ) ;
513+ await handleCreateChannel ( input , getCreateSuccess ( ) ?? undefined ) ;
519514 }
520515 } ,
521- [ browseDialogType , handleCreateChannel , handleCreateForum ] ,
516+ [
517+ browseDialogType ,
518+ handleCreateChannel ,
519+ handleCreateForum ,
520+ getCreateSuccess ,
521+ ] ,
522522 ) ;
523523
524524 const handleHideDm = React . useCallback (
0 commit comments