fix: workspace setting state
This commit is contained in:
parent
4fcc682a15
commit
7e48d13834
1 changed files with 11 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { Button, Select, Textarea, Option, Divider, Switch } from "@mui/joy";
|
import { Button, Select, Textarea, Option, Divider, Switch } from "@mui/joy";
|
||||||
import { isEqual } from "lodash-es";
|
import { isEqual } from "lodash-es";
|
||||||
import { ExternalLinkIcon } from "lucide-react";
|
import { ExternalLinkIcon } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { workspaceSettingNamePrefix, useWorkspaceSettingStore } from "@/store/v1";
|
import { workspaceSettingNamePrefix, useWorkspaceSettingStore } from "@/store/v1";
|
||||||
|
|
@ -18,16 +18,21 @@ const WorkspaceSection = () => {
|
||||||
);
|
);
|
||||||
const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState<WorkspaceGeneralSetting>(originalSetting);
|
const [workspaceGeneralSetting, setWorkspaceGeneralSetting] = useState<WorkspaceGeneralSetting>(originalSetting);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setWorkspaceGeneralSetting(originalSetting);
|
||||||
|
}, [workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL)]);
|
||||||
|
|
||||||
const handleUpdateCustomizedProfileButtonClick = () => {
|
const handleUpdateCustomizedProfileButtonClick = () => {
|
||||||
showUpdateCustomizedProfileDialog();
|
showUpdateCustomizedProfileDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
const updatePartialSetting = (partial: Partial<WorkspaceGeneralSetting>) => {
|
const updatePartialSetting = (partial: Partial<WorkspaceGeneralSetting>) => {
|
||||||
const newWorkspaceGeneralSetting = WorkspaceGeneralSetting.fromPartial({
|
setWorkspaceGeneralSetting(
|
||||||
...workspaceGeneralSetting,
|
WorkspaceGeneralSetting.fromPartial({
|
||||||
...partial,
|
...workspaceGeneralSetting,
|
||||||
});
|
...partial,
|
||||||
setWorkspaceGeneralSetting(newWorkspaceGeneralSetting);
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveGeneralSetting = async () => {
|
const handleSaveGeneralSetting = async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue