From 62919a9ff50e403a048f8a08a75b7ac642cbc22e Mon Sep 17 00:00:00 2001 From: JzoNg Date: Wed, 3 Apr 2024 18:04:09 +0800 Subject: [PATCH] app list mutation --- web/app/(commonLayout)/apps/Apps.tsx | 4 ++-- web/app/components/app-sidebar/app-info.tsx | 1 + web/context/app-context.tsx | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/app/(commonLayout)/apps/Apps.tsx b/web/app/(commonLayout)/apps/Apps.tsx index b753a6f8e4..597fa3f83f 100644 --- a/web/app/(commonLayout)/apps/Apps.tsx +++ b/web/app/(commonLayout)/apps/Apps.tsx @@ -53,7 +53,7 @@ const Apps = () => { const { data, isLoading, setSize, mutate } = useSWRInfinite( (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, searchKeywords), fetchAppList, - { revalidateFirstPage: false }, + { revalidateFirstPage: true }, ) const anchorRef = useRef(null) @@ -71,7 +71,7 @@ const Apps = () => { localStorage.removeItem(NEED_REFRESH_APP_LIST_KEY) mutate() } - }, [mutate, t]) + }, []) useEffect(() => { let observer: IntersectionObserver | undefined diff --git a/web/app/components/app-sidebar/app-info.tsx b/web/app/components/app-sidebar/app-info.tsx index cae044d7a6..abf488efe9 100644 --- a/web/app/components/app-sidebar/app-info.tsx +++ b/web/app/components/app-sidebar/app-info.tsx @@ -128,6 +128,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => { notify({ type: 'success', message: t('app.appDeleted') }) mutateApps() onPlanInfoChanged() + setAppDetail() replace('/apps') } catch (e: any) { diff --git a/web/context/app-context.tsx b/web/context/app-context.tsx index 3f15bba7ec..a9e7d69aea 100644 --- a/web/context/app-context.tsx +++ b/web/context/app-context.tsx @@ -58,6 +58,7 @@ const AppContext = createContext({ }, currentWorkspace: initialWorkspaceInfo, isCurrentWorkspaceManager: false, + isCurrentWorkspaceOwner: false, mutateUserProfile: () => { }, mutateCurrentWorkspace: () => { }, pageContainerRef: createRef(), @@ -76,7 +77,7 @@ export type AppContextProviderProps = { export const AppContextProvider: FC = ({ children }) => { const pageContainerRef = useRef(null) - const { data: appList, mutate: mutateApps } = useSWR({ url: '/apps', params: { page: 1 } }, fetchAppList) + const { data: appList, mutate: mutateApps } = useSWR({ url: '/apps', params: { page: 1, limit: 30, name: '' } }, fetchAppList) const { data: userProfileResponse, mutate: mutateUserProfile } = useSWR({ url: '/account/profile', params: {} }, fetchUserProfile) const { data: currentWorkspaceResponse, mutate: mutateCurrentWorkspace } = useSWR({ url: '/workspaces/current', params: {} }, fetchCurrentWorkspace)