fix: applist not refresh after customize

This commit is contained in:
金伟强 2023-05-25 14:18:15 +08:00
parent d33bb007f4
commit 542ac8e8a3
3 changed files with 12 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import NewAppCard from './NewAppCard'
import { AppListResponse } from '@/models/app'
import { fetchAppList } from '@/service/apps'
import { useSelector } from '@/context/app-context'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
const getKey = (pageIndex: number, previousPageData: AppListResponse) => {
if (!pageIndex || previousPageData.has_more)
@ -21,6 +22,13 @@ const Apps = () => {
const pageContainerRef = useSelector(state => state.pageContainerRef)
const anchorRef = useRef<HTMLAnchorElement>(null)
useEffect(() => {
if(localStorage.getItem(NEED_REFRESH_APP_LIST_KEY) === '1') {
localStorage.removeItem(NEED_REFRESH_APP_LIST_KEY)
mutate()
}
}, [])
useEffect(() => {
loadingStateRef.current = isLoading
}, [isLoading])

View File

@ -11,6 +11,7 @@ import { fetchAppList, installApp, fetchAppDetail } from '@/service/explore'
import { createApp } from '@/service/apps'
import CreateAppModal from '@/app/components/explore/create-app-modal'
import Loading from '@/app/components/base/loading'
import { NEED_REFRESH_APP_LIST_KEY } from '@/config'
import s from './style.module.css'
import Toast from '../../base/toast'
@ -64,6 +65,7 @@ const Apps: FC = ({ }) => {
type: 'success',
message: t('app.newApp.appCreated'),
})
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
router.push(`/app/${app.id}/overview`)
} catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })

View File

@ -99,5 +99,7 @@ export const VAR_ITEM_TEMPLATE = {
export const appDefaultIconBackground = '#D5F5F6'
export const NEED_REFRESH_APP_LIST_KEY = 'needRefreshAppList'