Skip to content

Commit

Permalink
implements reset in one minute after last message
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodeTherapy committed Nov 1, 2024
1 parent dcd2ff3 commit 0ba5d25
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

let queuedResponses = [];
let responseInProgress = false;
let latestMessageTime = document.timeline.currentTime;


class TextToCanvasImage {
Expand Down Expand Up @@ -382,6 +383,15 @@
if (diff > 10) {
textToCanvas.updateText(text);
}
} else {
const diff = Math.ceil((document.timeline.currentTime - latestMessageTime) / 1000);
if (diff > 60) {
latestPromise = null;
queuedMessages = [];
queuedResponses = [];
responseInProgress = false;
textToCanvas.updateText(text);
}
}
}

Expand Down Expand Up @@ -535,6 +545,7 @@

const chat = document.getElementById("chat");
chat.addEventListener("chat", (event) => {
latestMessageTime = document.timeline.currentTime;
const { message, connectionId } = event.detail;
submitMessage(message, connectionIdToUserId(connectionId));
});
Expand Down

0 comments on commit 0ba5d25

Please sign in to comment.