fix: duct-tape fix the bot edit issues

fixes #629
This commit is contained in:
Paul Makles 2022-06-21 11:14:51 +01:00
parent 3b7c1cbe20
commit 95ebd935ed
3 changed files with 4 additions and 26 deletions

View file

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

View file

@ -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));
}

View file

@ -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,6 +124,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
setSaving(true);
setError("");
try {
if (Object.keys(changes).length > 0)
await client.bots.edit(bot._id, changes);
if (changed) await editBotContent(profile?.content ?? undefined);
onUpdate(changes);
@ -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;
},
},
);