Tweak tracking script for easier debugging

This commit is contained in:
chylex 2024-12-31 04:55:53 +01:00
parent 737ab43ea4
commit f1c4cd040e
No known key found for this signature in database
2 changed files with 9 additions and 7 deletions

View File

@ -117,24 +117,25 @@ class DISCORD {
}
}
static getMessagesFromSelectedChannel() {
const channelId = this.#getCurrentlySelectedChannelId();
return channelId ? this.#getMessages(channelId) : null;
}
/**
* Calls the provided function with a list of messages whenever the currently loaded messages change.
* @param callback {function(server: ?DiscordGuild, channel: DiscordChannel, messages: Array<DiscordMessage>, hasMoreBefore: boolean)}
*/
static setupMessageCallback(callback) {
const previousMessages = new Set();
const onMessageElementsChanged = force => {
const channelId = this.#getCurrentlySelectedChannelId();
if (!channelId) {
return false;
}
const messages = this.#getMessages(channelId);
const messages = this.getMessagesFromSelectedChannel();
if (!messages || !messages.ready || messages.loadingMore) {
return false;
}
const channel = this.#channelStore.getChannel(channelId);
const channel = this.#channelStore.getChannel(messages.channelId);
if (!channel) {
return false;
}

View File

@ -73,6 +73,7 @@
/**
* @name MessageData
* @type {Object}
* @property {String} channelId
* @property {Boolean} ready
* @property {Boolean} loadingMore
* @property {Boolean} hasMoreAfter