From 740245b9822bb226cbe1f63b67f953f5579a6857 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Mon, 19 Jan 2026 18:10:05 +0800 Subject: [PATCH] no invalidateAppDetail --- web/app/components/app-sidebar/app-info.tsx | 13 +++--- web/app/components/app/store.ts | 44 ++++++++++++++++++++- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/web/app/components/app-sidebar/app-info.tsx b/web/app/components/app-sidebar/app-info.tsx index 6edd009b1e..e37ccdbfdb 100644 --- a/web/app/components/app-sidebar/app-info.tsx +++ b/web/app/components/app-sidebar/app-info.tsx @@ -18,15 +18,15 @@ import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' import CardView from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view' -import { appStoreSelectors, useAppStore } from '@/app/components/app/store' +import { appStoreActions, appStoreSelectors, useAppStore } from '@/app/components/app/store' import Button from '@/app/components/base/button' import ContentDialog from '@/app/components/base/content-dialog' import { ToastContext } from '@/app/components/base/toast' import { NEED_REFRESH_APP_LIST_KEY } from '@/config' import { useAppContext } from '@/context/app-context' import { useProviderContext } from '@/context/provider-context' -import { copyApp, deleteApp, exportAppConfig, updateAppInfo } from '@/service/apps' -import { useInvalidateAppDetail, useInvalidateAppList } from '@/service/use-apps' +import { copyApp, deleteApp, exportAppConfig } from '@/service/apps' +import { useInvalidateAppList } from '@/service/use-apps' import { fetchWorkflowDraft } from '@/service/workflow' import { AppModeEnum } from '@/types/app' import { getRedirection } from '@/utils/app-redirection' @@ -67,7 +67,6 @@ const AppInfo = ({ expand, onlyShowDetail = false, openState = false, onDetailEx const { appId } = useParams() const { onPlanInfoChanged } = useProviderContext() const appDetail = useAppStore(appStoreSelectors.appDetails(appId as string)) - const invalidateAppDetail = useInvalidateAppDetail() const invalidateAppList = useInvalidateAppList() const [open, setOpen] = useState(openState) const [showEditModal, setShowEditModal] = useState(false) @@ -90,7 +89,7 @@ const AppInfo = ({ expand, onlyShowDetail = false, openState = false, onDetailEx if (!appDetail) return try { - await updateAppInfo({ + await appStoreActions.updateAppDetail({ appID: appDetail.id, name, icon_type, @@ -105,12 +104,12 @@ const AppInfo = ({ expand, onlyShowDetail = false, openState = false, onDetailEx type: 'success', message: t('editDone', { ns: 'app' }), }) - invalidateAppDetail(appId as string) + // invalidateAppDetail(appId as string) } catch { notify({ type: 'error', message: t('editFailed', { ns: 'app' }) }) } - }, [appDetail, notify, invalidateAppDetail, appId, t]) + }, [appDetail, notify, appId, t]) const onCopy: DuplicateAppModalProps['onConfirm'] = async ({ name, icon_type, icon, icon_background }) => { if (!appDetail) diff --git a/web/app/components/app/store.ts b/web/app/components/app/store.ts index 2712fd80f2..3b6b08d6a6 100644 --- a/web/app/components/app/store.ts +++ b/web/app/components/app/store.ts @@ -1,7 +1,9 @@ import type { IChatItem } from '@/app/components/base/chat/chat/type' -import type { App, AppSSO } from '@/types/app' +import type { App, AppIconType, AppSSO } from '@/types/app' +import { cloneDeep } from 'es-toolkit/compat' import { shallow } from 'zustand/shallow' import { createWithEqualityFn } from 'zustand/traditional' +import { updateAppInfo } from '@/service/apps' import { get as serviceGet } from '@/service/base' type AppDetail = App & Partial @@ -81,6 +83,46 @@ async function fetchAppDetail(appID: string | undefined) { return appDetail } +async function updateAppDetail(updatedDetail: { + appID: string + name: string + icon_type: AppIconType + icon: string + icon_background?: string + description: string + use_icon_as_answer_icon?: boolean + max_active_requests?: number | null +}) { + const appID = updatedDetail.appID + const currentDetails = useAppStore.getState().appDetails || {} + const currentDetail = cloneDeep(currentDetails[appID]) + if (!currentDetail) + return + + set(state => ({ + appDetails: { + ...state.appDetails, + [appID]: { + ...currentDetail, + ...updatedDetail, + }, + }, + })) + + return updateAppInfo({ + ...updatedDetail, + appID, + }).catch(() => { + set(state => ({ + appDetails: { + ...state.appDetails, + [appID]: currentDetail, + }, + })) + }) +} + export const appStoreActions = { fetchAppDetail, + updateAppDetail, }