E-300 (#19726)
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: GareArc <chen4851@purdue.edu> Co-authored-by: Byron.wang <byron@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: KVOJJJin <jzongcode@gmail.com> Co-authored-by: Alexi.F <654973939@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: kautsar_masuara <61046989+izon-masuara@users.noreply.github.com> Co-authored-by: achmad-kautsar <achmad.kautsar@insignia.co.id> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: kelvintsim <83445753+kelvintsim@users.noreply.github.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: Zixuan Cheng <61724187+Theysua@users.noreply.github.com>
This commit is contained in:
@@ -6,17 +6,14 @@ import { createContext, useContext, useContextSelector } from 'use-context-selec
|
||||
import type { FC, ReactNode } from 'react'
|
||||
import { fetchAppList } from '@/service/apps'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import { fetchCurrentWorkspace, fetchLanggeniusVersion, fetchUserProfile, getSystemFeatures } from '@/service/common'
|
||||
import { fetchCurrentWorkspace, fetchLanggeniusVersion, fetchUserProfile } from '@/service/common'
|
||||
import type { App } from '@/types/app'
|
||||
import type { ICurrentWorkspace, LangGeniusVersionResponse, UserProfileResponse } from '@/models/common'
|
||||
import MaintenanceNotice from '@/app/components/header/maintenance-notice'
|
||||
import type { SystemFeatures } from '@/types/feature'
|
||||
import { defaultSystemFeatures } from '@/types/feature'
|
||||
import { noop } from 'lodash-es'
|
||||
|
||||
export type AppContextValue = {
|
||||
apps: App[]
|
||||
systemFeatures: SystemFeatures
|
||||
mutateApps: VoidFunction
|
||||
userProfile: UserProfileResponse
|
||||
mutateUserProfile: VoidFunction
|
||||
@@ -53,7 +50,6 @@ const initialWorkspaceInfo: ICurrentWorkspace = {
|
||||
}
|
||||
|
||||
const AppContext = createContext<AppContextValue>({
|
||||
systemFeatures: defaultSystemFeatures,
|
||||
apps: [],
|
||||
mutateApps: noop,
|
||||
userProfile: {
|
||||
@@ -92,10 +88,6 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
|
||||
const { data: userProfileResponse, mutate: mutateUserProfile } = useSWR({ url: '/account/profile', params: {} }, fetchUserProfile)
|
||||
const { data: currentWorkspaceResponse, mutate: mutateCurrentWorkspace, isLoading: isLoadingCurrentWorkspace } = useSWR({ url: '/workspaces/current', params: {} }, fetchCurrentWorkspace)
|
||||
|
||||
const { data: systemFeatures } = useSWR({ url: '/console/system-features' }, getSystemFeatures, {
|
||||
fallbackData: defaultSystemFeatures,
|
||||
})
|
||||
|
||||
const [userProfile, setUserProfile] = useState<UserProfileResponse>()
|
||||
const [langeniusVersionInfo, setLangeniusVersionInfo] = useState<LangGeniusVersionResponse>(initialLangeniusVersionInfo)
|
||||
const [currentWorkspace, setCurrentWorkspace] = useState<ICurrentWorkspace>(initialWorkspaceInfo)
|
||||
@@ -129,7 +121,6 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) =>
|
||||
return (
|
||||
<AppContext.Provider value={{
|
||||
apps: appList.data,
|
||||
systemFeatures: { ...defaultSystemFeatures, ...systemFeatures },
|
||||
mutateApps,
|
||||
userProfile,
|
||||
mutateUserProfile,
|
||||
|
Reference in New Issue
Block a user