From 95ebd935ed94056eb624b7bbfbd992c0102a6fa0 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Tue, 21 Jun 2022 11:14:51 +0100 Subject: [PATCH] fix: duct-tape fix the bot edit issues fixes #629 --- package.json | 2 +- .../intermediate/popovers/CreateBot.tsx | 1 + src/pages/settings/panes/MyBots.tsx | 27 ++----------------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 5ddb877b..7e7091a4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "1.0.1", "scripts": { "dev": "node scripts/setup_assets.js --check && vite", "pull": "node scripts/setup_assets.js", diff --git a/src/context/intermediate/popovers/CreateBot.tsx b/src/context/intermediate/popovers/CreateBot.tsx index 65a71443..45837755 100644 --- a/src/context/intermediate/popovers/CreateBot.tsx +++ b/src/context/intermediate/popovers/CreateBot.tsx @@ -29,6 +29,7 @@ export function CreateBotModal({ onClose, onCreate }: Props) { try { const { bot } = await client.bots.create({ name }); onCreate(bot); + onClose(); } catch (err) { setError(takeError(err)); } diff --git a/src/pages/settings/panes/MyBots.tsx b/src/pages/settings/panes/MyBots.tsx index a71f5a04..3cb64855 100644 --- a/src/pages/settings/panes/MyBots.tsx +++ b/src/pages/settings/panes/MyBots.tsx @@ -99,12 +99,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { client.api .get(`/users/${bot._id as ""}/profile`, undefined, { headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers?.["x-user-id"]; - delete headers?.["x-session-token"]; - return data; - }, }) .then((profile) => setProfile(profile ?? {})); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -130,7 +124,8 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { setSaving(true); setError(""); try { - await client.bots.edit(bot._id, changes); + if (Object.keys(changes).length > 0) + await client.bots.edit(bot._id, changes); if (changed) await editBotContent(profile?.content ?? undefined); onUpdate(changes); setChanged(false); @@ -159,12 +154,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { avatar ? { avatar } : { remove: ["Avatar"] }, { headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers?.["x-user-id"]; - delete headers?.["x-session-token"]; - return JSON.stringify(data); - }, }, ); @@ -184,12 +173,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { : { remove: ["ProfileBackground"] }, { headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers?.["x-user-id"]; - delete headers?.["x-session-token"]; - return JSON.stringify(data); - }, }, ); @@ -206,12 +189,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { content ? { profile: { content } } : { remove: ["ProfileContent"] }, { headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers?.["x-user-id"]; - delete headers?.["x-session-token"]; - return data; - }, }, );