Files
discord-decomp/lib/guild/GuildThreadSubscriptions.tsx
T
2026-11-01 12:12:55 +02:00

76 lines
1.6 KiB
TypeScript

// Metro module 6059 (f6060).
import LRUCache from "../../_bundle/LRUCache";
class GuildThreadSubscriptions {
constructor(a0) {
const r3 = {
__proto__: new.target.prototype,
_subscriptions: {}
};
r3._onChange = a0;
return r3;
}
reset() {
this._subscriptions = {};
}
get(a0) {
return this._get(a0).keys();
}
getSubscribedThreadIds() {
const set = new Set();
const _subscriptions = this._subscriptions;
for (const key in _subscriptions) {
for (const item of this._subscriptions[key].keys()) {
set.add(item);
}
}
return set;
}
_get(a0) {
let r8 = this._subscriptions[a0];
if (r8 == null) {
r8 = new LRUCache({
max: 3,
updateAgeOnGet: true
});
}
return r8;
}
clear(a0) {
if (a0 in this._subscriptions) {
delete this._subscriptions[a0];
this._onChange(a0, []);
}
}
subscribe(a0, a1, a2) {
let r29;
const r4 = this._get(a0);
if (r4.has(a1)) {
r4.set(a1, Date.now());
r29 = false;
} else {
if (a2 != null && r4.has(a2)) {
r4.set(a2, Date.now());
}
r4.set(a1, Date.now());
this._subscriptions[a0] = r4;
this._onChange(a0, r4.keys());
r29 = true;
}
return r29;
}
unsubscribe(a0, a1) {
if (a0 in this._subscriptions) {
const r6 = this._subscriptions[a0];
let r12 = !!r6.has(a1);
if (r12) {
r6.del(a1);
this._onChange(a0, r6.keys());
r12 = true;
}
return r12;
}
return false;
}
}
export default GuildThreadSubscriptions;