Skip to content

Commit

Permalink
fix webhooks, fix mouseout event, idk what else i wanted to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
be195 committed Apr 3, 2024
1 parent adf88d5 commit d198ada
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ class Artboard {
this.onResize = this.onResize.bind(this);
this.onMouseDown = this.onMouseDown.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
this.onMouseOut = this.onMouseOut.bind(this);
this.onMouseMove = this.onMouseMove.bind(this);
this.onWheel = this.onWheel.bind(this);
this.renderCanvas = this.renderCanvas.bind(this);
this.processReceivedMessage = this.processReceivedMessage.bind(this);

window.addEventListener('resize', this.onResize);
this.canvas.addEventListener('mouseup', this.onMouseUp);
this.canvas.addEventListener('mouseout', this.onMouseUp);
this.canvas.addEventListener('mouseout', this.onMouseOut);
this.canvas.addEventListener('mousedown', this.onMouseDown);
this.canvas.addEventListener('mousemove', this.onMouseMove);
this.canvas.addEventListener('wheel', this.onWheel);
Expand All @@ -64,6 +65,10 @@ class Artboard {
if (!this.drag)
this.updateInformationElement(true);

this.onMouseOut();
}

onMouseOut() {
this.click = false;
this.drag = false;
}
Expand Down
8 changes: 5 additions & 3 deletions src/structures/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export default class Game extends BaseStructure {
const uniquePixels = image.filter(color => color !== -1);
const size = this.dimensions[0] * this.dimensions[1];

let method = 'PATCH';
let url = `${this.webhookURL}/messages/${this.msgID}`;
const lastField = {
name: 'Next Reset:',
Expand All @@ -189,6 +190,7 @@ export default class Game extends BaseStructure {
};

if (toArchive) {
method = 'POST';
url = this.webhookArchiveURL;
lastField.name = 'Total Participants:';
lastField.value = String(uniqueIDs.size);
Expand Down Expand Up @@ -231,11 +233,11 @@ export default class Game extends BaseStructure {
filename: 'image.png',
});

const formHeaders = formData.getHeaders();
const headers = formData.getHeaders();

return fetch(url, {
method: 'POST',
headers: formHeaders,
method,
headers,
body: formData as any,
});
}
Expand Down

0 comments on commit d198ada

Please sign in to comment.