Skip to content

Commit

Permalink
Suspects: Don't re-send suspect-create on test edit
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Oct 27, 2024
1 parent d0c96f8 commit e98a544
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions server/chat-plugins/suspect-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ export const commands: Chat.ChatCommands = {
}
reqData[k] = val;
}

const [out, error] = await LoginServer.request("suspects/add", {
format: format.id,
reqs: JSON.stringify(reqData),
url: urlActual,
});
if (out?.actionerror || error) {
throw new Chat.ErrorMessage("Error adding suspect test: " + (out?.actionerror || error?.message));
const isEdit = suspectTests.suspects[format.id];
if (!isEdit) {
const [out, error] = await LoginServer.request("suspects/add", {
format: format.id,
reqs: JSON.stringify(reqData),
url: urlActual,
});
if (out?.actionerror || error) {
throw new Chat.ErrorMessage("Error adding suspect test: " + (out?.actionerror || error?.message));
}
}

this.privateGlobalModAction(`${user.name} ${suspectTests.suspects[format.id] ? "edited the" : "added a"} ${format.name} suspect test.`);
Expand Down

0 comments on commit e98a544

Please sign in to comment.