Skip to content

Commit

Permalink
Merge pull request #136 from redweller/fix/randomcrash
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGiddyLimit authored Sep 21, 2022
2 parents 8683914 + cdc470b commit 18ab299
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions js/base-qpi.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,31 @@ function baseQpi () {
on: {
_preInit () {
qpi._on_chatHandlers = [];
const seenMessages = new Set();
d20.textchat.chatref = d20.textchat.shoutref.parent.child("chat");
const handleChat = (e) => {
if (!d20.textchat.chatstartingup) {
e.id = e.key;
if (!seenMessages.has(e.id)) {
seenMessages.add(e.id);
if (d20.textchat.shoutref) {
const seenMessages = new Set();
d20.textchat.chatref = d20.textchat.shoutref.parent.child("chat");
const handleChat = (e) => {
if (!d20.textchat.chatstartingup) {
e.id = e.key;
if (!seenMessages.has(e.id)) {
seenMessages.add(e.id);

let t = e.val();
if (t) {
// eslint-disable-next-line no-console
if (window.DEBUG) console.log("CHAT: ", t);
let t = e.val();
if (t) {
// eslint-disable-next-line no-console
if (window.DEBUG) console.log("CHAT: ", t);

qpi._on_chatHandlers.forEach(fn => fn(t));
qpi._on_chatHandlers.forEach(fn => fn(t));
}
}
}
}
};
d20.textchat.chatref.on("child_added", handleChat);
d20.textchat.chatref.on("child_changed", handleChat);
};
d20.textchat.chatref.on("child_added", handleChat);
d20.textchat.chatref.on("child_changed", handleChat);
} else {
// eslint-disable-next-line no-console
console.warn("%cQPI > ", "color: #b93032; font-size: large", "Can't properly initialize chat handler");
}
},
_ (evtType, fn, ...others) {
switch (evtType) {
Expand Down

0 comments on commit 18ab299

Please sign in to comment.