From 4e5810e20568a65c7ae4e617ed18104213638c78 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 28 Aug 2024 23:29:30 +0800 Subject: [PATCH] chore: update workspace setting section --- .../components/Settings/WorkspaceSection.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/web/src/components/Settings/WorkspaceSection.tsx b/web/src/components/Settings/WorkspaceSection.tsx index 0315ac26..e806dec4 100644 --- a/web/src/components/Settings/WorkspaceSection.tsx +++ b/web/src/components/Settings/WorkspaceSection.tsx @@ -1,9 +1,9 @@ import { Button, Select, Textarea, Option, Divider } from "@mui/joy"; +import { isEqual } from "lodash-es"; import { ExternalLinkIcon } from "lucide-react"; import { useState } from "react"; import { toast } from "react-hot-toast"; import { Link } from "react-router-dom"; -import { workspaceSettingServiceClient } from "@/grpcweb"; import { workspaceSettingNamePrefix, useWorkspaceSettingStore } from "@/store/v1"; import { WorkspaceGeneralSetting } from "@/types/proto/api/v1/workspace_setting_service"; import { WorkspaceSettingKey } from "@/types/proto/store/workspace_setting"; @@ -13,9 +13,10 @@ import showUpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog" const WorkspaceSection = () => { const t = useTranslate(); const workspaceSettingStore = useWorkspaceSettingStore(); - const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState( - WorkspaceGeneralSetting.fromPartial(workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL)?.generalSetting || {}), + const originalSetting = WorkspaceGeneralSetting.fromPartial( + workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL)?.generalSetting || {}, ); + const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState(originalSetting); const handleUpdateCustomizedProfileButtonClick = () => { showUpdateCustomizedProfileDialog(); @@ -35,11 +36,9 @@ const WorkspaceSection = () => { const handleSaveGeneralSetting = async () => { try { - await workspaceSettingServiceClient.setWorkspaceSetting({ - setting: { - name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.GENERAL}`, - generalSetting: workspaceGeneralSetting, - }, + await workspaceSettingStore.setWorkspaceSetting({ + name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.GENERAL}`, + generalSetting: workspaceGeneralSetting, }); } catch (error: any) { toast.error(error.details); @@ -118,8 +117,8 @@ const WorkspaceSection = () => { -
-