From 0d791839e619ace81c3e601bb4d03e155ec5fc45 Mon Sep 17 00:00:00 2001 From: bowen <54492610+jiaowoxiaobala@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:33:45 +0800 Subject: [PATCH] =?UTF-8?q?perf=EF=BC=9Arepeated=20select=20workspace=20(#?= =?UTF-8?q?710)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../header/account-dropdown/workplace-selector/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/app/components/header/account-dropdown/workplace-selector/index.tsx b/web/app/components/header/account-dropdown/workplace-selector/index.tsx index 6798bc4fa3..b7ed414e6d 100644 --- a/web/app/components/header/account-dropdown/workplace-selector/index.tsx +++ b/web/app/components/header/account-dropdown/workplace-selector/index.tsx @@ -27,10 +27,11 @@ const WorkplaceSelector = () => { const { t } = useTranslation() const { notify } = useContext(ToastContext) const { workspaces } = useWorkspacesContext() - const currentWrokspace = workspaces.filter(item => item.current)?.[0] + const currentWorkspace = workspaces.find(v => v.current) const handleSwitchWorkspace = async (tenant_id: string) => { try { + if (currentWorkspace?.id === tenant_id) return await switchWorkspace({ url: '/workspaces/switch', body: { tenant_id } }) notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) location.assign(`${location.origin}`) @@ -51,8 +52,8 @@ const WorkplaceSelector = () => { group hover:bg-gray-50 cursor-pointer ${open && 'bg-gray-50'} rounded-lg `, )}> -
{currentWrokspace?.name[0].toLocaleUpperCase()}
-
{currentWrokspace?.name}
+
{currentWorkspace?.name[0].toLocaleUpperCase()}
+
{currentWorkspace?.name}