app list mutation

This commit is contained in:
JzoNg 2024-04-03 18:04:09 +08:00
parent e13f8da9d5
commit 62919a9ff5
3 changed files with 5 additions and 3 deletions

View File

@ -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<HTMLDivElement>(null)
@ -71,7 +71,7 @@ const Apps = () => {
localStorage.removeItem(NEED_REFRESH_APP_LIST_KEY)
mutate()
}
}, [mutate, t])
}, [])
useEffect(() => {
let observer: IntersectionObserver | undefined

View File

@ -128,6 +128,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => {
notify({ type: 'success', message: t('app.appDeleted') })
mutateApps()
onPlanInfoChanged()
setAppDetail()
replace('/apps')
}
catch (e: any) {

View File

@ -58,6 +58,7 @@ const AppContext = createContext<AppContextValue>({
},
currentWorkspace: initialWorkspaceInfo,
isCurrentWorkspaceManager: false,
isCurrentWorkspaceOwner: false,
mutateUserProfile: () => { },
mutateCurrentWorkspace: () => { },
pageContainerRef: createRef(),
@ -76,7 +77,7 @@ export type AppContextProviderProps = {
export const AppContextProvider: FC<AppContextProviderProps> = ({ children }) => {
const pageContainerRef = useRef<HTMLDivElement>(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)