fix: unable to update profiles in some cases

This commit is contained in:
naskya 2024-01-15 02:00:18 +09:00
parent 595fe24471
commit 15dabfc878
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -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,