From aab5566d980f3c715c819816dc99ae425ead3651 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Tue, 19 Mar 2024 18:49:26 +0800 Subject: [PATCH] fix app switch --- web/app/components/app-sidebar/app-info.tsx | 1 + web/app/components/app/switch-app-modal/index.tsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/app/components/app-sidebar/app-info.tsx b/web/app/components/app-sidebar/app-info.tsx index ec9e2f2bff..8f906c25a2 100644 --- a/web/app/components/app-sidebar/app-info.tsx +++ b/web/app/components/app-sidebar/app-info.tsx @@ -304,6 +304,7 @@ const AppInfo = ({ expand }: IAppInfoProps) => { {showSwitchModal && ( setShowSwitchModal(false)} diff --git a/web/app/components/app/switch-app-modal/index.tsx b/web/app/components/app/switch-app-modal/index.tsx index bdecb9ebe3..fa8ecd333e 100644 --- a/web/app/components/app/switch-app-modal/index.tsx +++ b/web/app/components/app/switch-app-modal/index.tsx @@ -20,18 +20,21 @@ import { getRedirection } from '@/utils/app-redirection' import type { App } from '@/types/app' import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' import AppIcon from '@/app/components/base/app-icon' +import { useStore as useAppStore } from '@/app/components/app/store' type SwitchAppModalProps = { show: boolean appDetail: App onSuccess?: () => void onClose: () => void + inAppDetail?: boolean } -const SwitchAppModal = ({ show, appDetail, onSuccess, onClose }: SwitchAppModalProps) => { +const SwitchAppModal = ({ show, appDetail, inAppDetail = false, onSuccess, onClose }: SwitchAppModalProps) => { const { push, replace } = useRouter() const { t } = useTranslation() const { notify } = useContext(ToastContext) + const { setAppDetail } = useAppStore() const { isCurrentWorkspaceManager } = useAppContext() const { plan, enableBilling } = useProviderContext() @@ -50,12 +53,17 @@ const SwitchAppModal = ({ show, appDetail, onSuccess, onClose }: SwitchAppModalP if (onClose) onClose() notify({ type: 'success', message: t('app.newApp.appCreated') }) + if (inAppDetail) + setAppDetail() if (removeOriginal) await deleteApp(appDetail.id) localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') getRedirection( isCurrentWorkspaceManager, - { id: newAppID }, + { + id: newAppID, + mode: appDetail.mode === 'completion' ? 'workflow' : 'advanced-chat', + }, removeOriginal ? replace : push, ) }