mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 21:05:06 +03:00
clean
This commit is contained in:
1 parent
16a1037e36
commit
ce23b79ebb
1 file changed
+5
-7
+5
-7
@@ -15,30 +15,28 @@ export const LayoutSidebarProvider = ({ children }: PropsWithChildren) => {
|
||||
const assistantComponent = useCallback(() => <AIAssistant />, [])
|
||||
useRegisterSidebar(SIDEBAR_KEYS.AI_ASSISTANT, assistantComponent, {}, 'i')
|
||||
|
||||
const router = useRouter()
|
||||
const { sidebars } = useSidebarManagerSnapshot()
|
||||
const appliedUrlSidebarRef = useRef<string | null>(null)
|
||||
|
||||
// Set sidebar state initially based on URL query param
|
||||
const router = useRouter()
|
||||
const sidebarParamRaw = router.query.sidebar
|
||||
const sidebarParam = useMemo(
|
||||
() => (typeof sidebarParamRaw === 'string' ? sidebarParamRaw : null),
|
||||
[sidebarParamRaw]
|
||||
)
|
||||
const registeredSidebar = sidebarParam ? sidebars[sidebarParam] : undefined
|
||||
|
||||
useEffect(() => {
|
||||
if (!router.isReady) return
|
||||
|
||||
if (!sidebarParam) {
|
||||
appliedUrlSidebarRef.current = null
|
||||
return
|
||||
}
|
||||
const registeredSidebar = sidebars[sidebarParam]
|
||||
|
||||
if (!registeredSidebar) return
|
||||
if (appliedUrlSidebarRef.current === sidebarParam) return
|
||||
|
||||
sidebarManagerState.openSidebar(sidebarParam)
|
||||
appliedUrlSidebarRef.current = sidebarParam
|
||||
}, [router.isReady, sidebarParam, registeredSidebar])
|
||||
}, [router.isReady, sidebarParam])
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
Reference in new issue
Block a user