From 15dabfc878a67c76db9c4d7fe8664287067e25cb Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 15 Jan 2024 02:00:18 +0900 Subject: [PATCH] fix: unable to update profiles in some cases --- packages/client/src/pages/settings/profile.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue index 98b312ac..e86a2a67 100644 --- a/packages/client/src/pages/settings/profile.vue +++ b/packages/client/src/pages/settings/profile.vue @@ -229,13 +229,16 @@ function saveFields() { }); } +const convertEmptyStringToNull = (x) => + x === "" ? null : x == null ? undefined : x; + function save() { os.apiWithDialog("i/update", { - name: profile.name ?? undefined, - description: profile.description ?? undefined, - location: profile.location ?? undefined, - birthday: profile.birthday ?? undefined, - lang: profile.lang ?? undefined, + name: convertEmptyStringToNull(profile.name), + description: convertEmptyStringToNull(profile.description), + location: convertEmptyStringToNull(profile.location), + birthday: convertEmptyStringToNull(profile.birthday), + lang: convertEmptyStringToNull(profile.lang), isBot: !!profile.isBot, isCat: !!profile.isCat, speakAsCat: profile.isCat ? !!profile.speakAsCat : undefined,