Skip to content

Commit

Permalink
fix: only combo user messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Dec 27, 2023
1 parent dac7c0b commit a64c5e7
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,30 +1074,32 @@ class Chat {
const textonly = Chat.removeSlashCmdFromText(data.data);
const usr = this.users.get(data.nick.toLowerCase());
const win = this.mainwindow;
if (
win.lastmessage !== null &&
const isCombo =
this.emoteService.canUserUseEmote(usr, textonly) &&
Chat.removeSlashCmdFromText(win.lastmessage.message) === textonly
) {
if (win.lastmessage.type === MessageTypes.EMOTE) {
win.lastmessage.incEmoteCount();
Chat.removeSlashCmdFromText(win.lastmessage?.message) === textonly;

if (this.user.equalWatching(usr.watching)) {
win.lastmessage.ui.classList.toggle('watching-same', true);
}
if (isCombo && win.lastmessage?.type === MessageTypes.EMOTE) {
win.lastmessage.incEmoteCount();

this.mainwindow.update();
} else {
win.removeLastMessage();
const msg = MessageBuilder.emote(textonly, data.timestamp, 2).into(
this,
);
if (this.user.equalWatching(usr.watching)) {
win.lastmessage.ui.classList.toggle('watching-same', true);
}

if (this.user.equalWatching(usr.watching)) {
msg.ui.classList.add('watching-same');
}
this.mainwindow.update();
return;
}

if (isCombo && win.lastmessage?.type === MessageTypes.USER) {
win.removeLastMessage();
const msg = MessageBuilder.emote(textonly, data.timestamp, 2).into(this);

if (this.user.equalWatching(usr.watching)) {
msg.ui.classList.add('watching-same');
}
} else if (!this.resolveMessage(data.nick, data.data)) {
return;
}

if (!this.resolveMessage(data.nick, data.data)) {
MessageBuilder.message(data.data, usr, data.timestamp).into(this);
}
}
Expand Down Expand Up @@ -2337,7 +2339,7 @@ class Chat {
}

static removeSlashCmdFromText(msg) {
return msg.replace(regexslashcmd, '').trim();
return msg?.replace(regexslashcmd, '').trim();
}

static extractNicks(text) {
Expand Down

0 comments on commit a64c5e7

Please sign in to comment.