mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-07 13:50:56 +00:00
4.43.0
* Added: Automatically reprocess chat messages when loading a channel for the first time. (Closes #1333) * Fixed: Random emotes being insert into chat when using the emote menu in some situations. (Closes #1337) * Fixed: When tokenizing messages, ignore fake emotes injected into Twitch's chat handler for the purpose of auto-completion and WYSIWYG support. * Changed: Switch to a better method for how to get `require` from webpack. * Changed: Update the logic used to calculate the container size when overlaying emotes. * API Added: `load_tracker` module for waiting for multiple events to finish. This is used to reprocess chat lines once every data source has finished loading to avoid multiple unnecessary updates. * API Added: Add-ons can now set a `load_events` array in their manifest to have the add-on loader register them with `load_tracker`, ensuring events don't fire before the add-on is able to execute.
This commit is contained in:
parent
e26f836267
commit
daa193aa03
17 changed files with 481 additions and 68 deletions
77
src/load_tracker.jsx
Normal file
77
src/load_tracker.jsx
Normal file
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
|
||||
// ============================================================================
|
||||
// Loading Tracker
|
||||
// ============================================================================
|
||||
|
||||
import Module from 'utilities/module';
|
||||
|
||||
export default class LoadTracker extends Module {
|
||||
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.should_enable = true;
|
||||
|
||||
this.inject('settings');
|
||||
|
||||
this.settings.add('chat.update-when-loaded', {
|
||||
default: true,
|
||||
ui: {
|
||||
path: 'Chat > Behavior >> General',
|
||||
title: 'Update existing chat messages when loading new data.',
|
||||
component: 'setting-check-box',
|
||||
description: 'This may cause elements in chat to move, so you may wish to disable this when performing moderation.'
|
||||
}
|
||||
});
|
||||
|
||||
this.pending_loads = new Map;
|
||||
|
||||
this.on(':schedule', this.schedule, this);
|
||||
|
||||
}
|
||||
|
||||
schedule(type, key) {
|
||||
let data = this.pending_loads.get(type);
|
||||
if ( ! data || ! data.pending || ! data.timers ) {
|
||||
data = {
|
||||
pending: new Set,
|
||||
timers: {},
|
||||
success: false
|
||||
};
|
||||
this.pending_loads.set(type, data);
|
||||
}
|
||||
|
||||
if ( data.pending.has(key) )
|
||||
return;
|
||||
|
||||
data.pending.add(key);
|
||||
data.timers[key] = setTimeout(() => this.notify(type, key, false), 15000);
|
||||
}
|
||||
|
||||
notify(type, key, success = true) {
|
||||
const data = this.pending_loads.get(type);
|
||||
if ( ! data || ! data.pending || ! data.timers )
|
||||
return;
|
||||
|
||||
if ( data.timers[key] ) {
|
||||
clearTimeout(data.timers[key]);
|
||||
data.timers[key] = null;
|
||||
}
|
||||
|
||||
if ( ! data.pending.has(key) )
|
||||
return;
|
||||
|
||||
data.pending.delete(key);
|
||||
if ( success )
|
||||
data.success = true;
|
||||
|
||||
if ( ! data.pending.size ) {
|
||||
this.log.debug('complete', type, Object.keys(data.timers));
|
||||
if ( data.success )
|
||||
this.emit(`:complete:${type}`);
|
||||
this.pending_loads.delete(type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue