Skip to content

Commit

Permalink
No longer add events when loading from history
Browse files Browse the repository at this point in the history
The `PAIDEVENTS` payload will contain all the events in history.
  • Loading branch information
11k committed Nov 13, 2024
1 parent 5988826 commit bf7b3a5
Showing 1 changed file with 42 additions and 20 deletions.
62 changes: 42 additions & 20 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1350,41 +1350,63 @@ class Chat {

onSUBSCRIPTION(data) {
MessageBuilder.subscription(data).into(this);
const eventBarEvent = new EventBarEvent(
this,
MessageTypes.SUBSCRIPTION,
data,
);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();

// Don't add events when loading messages from history because the
// `PAIDEVENTS` payload will contain those events
if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(
this,
MessageTypes.SUBSCRIPTION,
data,
);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();
}
}
}

onGIFTSUB(data) {
MessageBuilder.gift(data).into(this);
const eventBarEvent = new EventBarEvent(this, MessageTypes.GIFTSUB, data);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();

if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(this, MessageTypes.GIFTSUB, data);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();
}
}
}

onMASSGIFT(data) {
MessageBuilder.massgift(data).into(this);
const eventBarEvent = new EventBarEvent(this, MessageTypes.MASSGIFT, data);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();

if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(
this,
MessageTypes.MASSGIFT,
data,
);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();
}
}
}

onDONATION(data) {
MessageBuilder.donation(data).into(this);
const eventBarEvent = new EventBarEvent(this, MessageTypes.DONATION, data);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();

if (!this.backlogloading) {
const eventBarEvent = new EventBarEvent(
this,
MessageTypes.DONATION,
data,
);
this.eventBar.add(eventBarEvent);
if (this.eventBar.length === 1) {
this.mainwindow.update();
}
}
}

Expand Down

0 comments on commit bf7b3a5

Please sign in to comment.