1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00

Use ref-counting with socket topic subscriptions to make it easy to tell when we should and shouldn't actually unsubscribe. Add route awareness to FineWrapper so that we can unregister the MutationObserver when we know we won't be suddenly finding an instance that we're looking for. Have the channel bar register for the channel pubsub topic. Fix minimize navigation showing the navigation bar over top of theater mode.

This commit is contained in:
SirStendec 2018-03-14 13:58:04 -04:00
parent c559790f87
commit 254d297f79
17 changed files with 160 additions and 71 deletions

View file

@ -43,7 +43,7 @@ export default class SocketClient extends Module {
this._want_connected = false;
this._topics = new Set;
this._topics = new Map;
this._pending = [];
this._awaiting = new Map;
@ -426,30 +426,42 @@ export default class SocketClient extends Module {
// Topics
// ========================================================================
subscribe(...topics) {
subscribe(referrer, ...topics) {
const t = this._topics;
for(const topic of topics) {
if ( this.connected && ! t.has(topic) )
this._send('sub', topic);
if ( ! t.has(topic) ) {
if ( this.connected )
this._send('sub', topic);
t.add(topic);
t.set(topic, new Set);
}
const tp = t.get(topic);
tp.add(referrer);
}
}
unsubscribe(...topics) {
unsubscribe(referrer, ...topics) {
const t = this._topics;
for(const topic of topics) {
if ( this.connected && t.has(topic) )
this._send('unsub', topic);
if ( ! t.has(topic) )
continue;
t.delete(topic);
const tp = t.get(topic);
tp.delete(referrer);
if ( ! tp.size ) {
t.delete(topic);
if ( this.connected )
this._send('unsub', topic);
}
}
}
get topics() {
return Array.from(this._topics);
return Array.from(this._topics.keys());
}
}