|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import { createRef, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
|
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
|
|
|
import useSWR from 'swr'
|
|
|
|
|
import { createContext, useContext, useContextSelector } from 'use-context-selector'
|
|
|
|
|
import type { FC, ReactNode } from 'react'
|
|
|
|
|
@ -18,7 +18,6 @@ export type AppContextValue = {
|
|
|
|
|
isCurrentWorkspaceEditor: boolean
|
|
|
|
|
isCurrentWorkspaceDatasetOperator: boolean
|
|
|
|
|
mutateCurrentWorkspace: VoidFunction
|
|
|
|
|
pageContainerRef: React.RefObject<HTMLDivElement | null>
|
|
|
|
|
langGeniusVersionInfo: LangGeniusVersionResponse
|
|
|
|
|
useSelector: typeof useSelector
|
|
|
|
|
isLoadingCurrentWorkspace: boolean
|
|
|
|
|
@ -62,7 +61,6 @@ const AppContext = createContext<AppContextValue>({
|
|
|
|
|
isCurrentWorkspaceDatasetOperator: false,
|
|
|
|
|
mutateUserProfile: noop,
|
|
|
|
|
mutateCurrentWorkspace: noop,
|
|
|
|
|
pageContainerRef: createRef(),
|
|
|
|
|
langGeniusVersionInfo: initialLangGeniusVersionInfo,
|
|
|
|
|
useSelector,
|
|
|
|
|
isLoadingCurrentWorkspace: false,
|
|
|
|
|
@ -77,7 +75,6 @@ export type AppContextProviderProps = {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) => {
|
|
|
|
|
const pageContainerRef = useRef<HTMLDivElement>(null)
|
|
|
|
|
const { data: userProfileResponse, mutate: mutateUserProfile } = useSWR({ url: '/account/profile', params: {} }, fetchUserProfile)
|
|
|
|
|
const { data: currentWorkspaceResponse, mutate: mutateCurrentWorkspace, isLoading: isLoadingCurrentWorkspace } = useSWR({ url: '/workspaces/current', params: {} }, fetchCurrentWorkspace)
|
|
|
|
|
|
|
|
|
|
@ -112,7 +109,6 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
|
|
|
|
|
<AppContext.Provider value={{
|
|
|
|
|
userProfile,
|
|
|
|
|
mutateUserProfile,
|
|
|
|
|
pageContainerRef,
|
|
|
|
|
langGeniusVersionInfo,
|
|
|
|
|
useSelector,
|
|
|
|
|
currentWorkspace,
|
|
|
|
|
@ -125,7 +121,7 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
|
|
|
|
|
}}>
|
|
|
|
|
<div className='flex h-full flex-col overflow-y-auto'>
|
|
|
|
|
{globalThis.document?.body?.getAttribute('data-public-maintenance-notice') && <MaintenanceNotice />}
|
|
|
|
|
<div ref={pageContainerRef} className='relative flex grow flex-col overflow-y-auto overflow-x-hidden bg-background-body'>
|
|
|
|
|
<div className='relative flex grow flex-col overflow-y-auto overflow-x-hidden bg-background-body'>
|
|
|
|
|
{children}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|