mirror of
https://github.com/usememos/memos.git
synced 2026-12-04 04:04:21 +01:00
refactor: migrate to connect-rpc (#5338)
This commit is contained in:
1 parent
8af8b9d238
commit
edd3ced9bf
151 files changed
+14556
-27933
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
import { useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -7,7 +8,12 @@ import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { instanceStore } from "@/store";
|
||||
import { instanceSettingNamePrefix } from "@/store/common";
|
||||
import { InstanceSetting_GeneralSetting_CustomProfile, InstanceSetting_Key } from "@/types/proto/api/v1/instance_service";
|
||||
import {
|
||||
InstanceSetting_GeneralSetting_CustomProfile,
|
||||
InstanceSetting_GeneralSetting_CustomProfileSchema,
|
||||
InstanceSetting_Key,
|
||||
InstanceSettingSchema,
|
||||
} from "@/types/proto/api/v1/instance_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
|
||||
interface Props {
|
||||
@@ -20,7 +26,7 @@ function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props)
|
||||
const t = useTranslate();
|
||||
const instanceGeneralSetting = instanceStore.state.generalSetting;
|
||||
const [customProfile, setCustomProfile] = useState<InstanceSetting_GeneralSetting_CustomProfile>(
|
||||
InstanceSetting_GeneralSetting_CustomProfile.fromPartial(instanceGeneralSetting.customProfile || {}),
|
||||
create(InstanceSetting_GeneralSetting_CustomProfileSchema, instanceGeneralSetting.customProfile || {}),
|
||||
);
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -70,13 +76,18 @@ function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props)
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await instanceStore.upsertInstanceSetting({
|
||||
name: `${instanceSettingNamePrefix}${InstanceSetting_Key.GENERAL}`,
|
||||
generalSetting: {
|
||||
...instanceGeneralSetting,
|
||||
customProfile: customProfile,
|
||||
},
|
||||
});
|
||||
await instanceStore.upsertInstanceSetting(
|
||||
create(InstanceSettingSchema, {
|
||||
name: `${instanceSettingNamePrefix}${InstanceSetting_Key.GENERAL}`,
|
||||
value: {
|
||||
case: "generalSetting",
|
||||
value: {
|
||||
...instanceGeneralSetting,
|
||||
customProfile: customProfile,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
toast.success(t("message.update-succeed"));
|
||||
onSuccess?.();
|
||||
onOpenChange(false);
|
||||
|
||||
Reference in new issue
Block a user