163 lines
5.0 KiB
TypeScript
163 lines
5.0 KiB
TypeScript
// Metro module 6056 (f6057).
|
|
import { ME } from "../../Constants";
|
|
import { isFavoritesGuildId } from "../../modules/favorites/FavoritesUtils";
|
|
import GuildMemberSubscriptions from "./GuildMemberSubscriptions";
|
|
import * as _GuildChannelSubscriptions from "./GuildChannelSubscriptions";
|
|
import GuildChannelSubscriptions from "./GuildChannelSubscriptions";
|
|
import GuildThreadSubscriptions from "./GuildThreadSubscriptions";
|
|
import { DelayedCall } from "../../_bundle/Timeout";
|
|
import Module12 from "../../_bundle/Module12";
|
|
class GuildSubscriptions {
|
|
_members = new GuildMemberSubscriptions((a0, a1) => this._enqueue(a0, {
|
|
members: a1
|
|
}));
|
|
_channels = new GuildChannelSubscriptions((a0, a1) => this._enqueue(a0, {
|
|
channels: a1
|
|
}));
|
|
_threadMemberLists = new GuildThreadSubscriptions((a0, a1) => this._enqueue(a0, {
|
|
thread_member_lists: a1
|
|
}));
|
|
_typing = new Set();
|
|
_threads = new Set();
|
|
_activities = new Set();
|
|
_memberUpdates = new Set();
|
|
_subscribed = new Set();
|
|
_pending = {};
|
|
_flush = new DelayedCall(0, () => this.flush());
|
|
constructor(a0) {
|
|
this._onChange = a0;
|
|
}
|
|
_enqueue(a0, a1) {
|
|
this._pending[a0] = {
|
|
...this._pending[a0],
|
|
...a1
|
|
};
|
|
this._flush.delay();
|
|
}
|
|
reset() {
|
|
this._subscribed.clear();
|
|
this._pending = {};
|
|
this._members.reset();
|
|
this._memberUpdates.clear();
|
|
this._channels.reset();
|
|
this._threadMemberLists.reset();
|
|
this._typing.clear();
|
|
this._threads.clear();
|
|
this._activities.clear();
|
|
}
|
|
get(a0) {
|
|
return {
|
|
typing: this._typing.has(a0),
|
|
threads: this._threads.has(a0),
|
|
activities: this._activities.has(a0),
|
|
members: this._members.get(a0),
|
|
member_updates: this._memberUpdates.has(a0),
|
|
channels: this._channels.get(a0),
|
|
thread_member_lists: this._threadMemberLists.get(a0)
|
|
};
|
|
}
|
|
getSubscribedThreadIds() {
|
|
return this._threadMemberLists.getSubscribedThreadIds();
|
|
}
|
|
isSubscribedToThreads(a0) {
|
|
return this._threads.has(a0);
|
|
}
|
|
isSubscribedToAnyMember(a0) {
|
|
let r5 = this._members.isSubscribedToAnyMember(a0);
|
|
if (r5 == null) {
|
|
r5 = false;
|
|
}
|
|
return r5;
|
|
}
|
|
isSubscribedToMemberUpdates(a0) {
|
|
let member_updates = this.get(a0).member_updates;
|
|
if (member_updates == null) {
|
|
member_updates = false;
|
|
}
|
|
return member_updates;
|
|
}
|
|
forEach(a0) {
|
|
this._subscribed.forEach(a0);
|
|
}
|
|
clearWithoutFlushing(a0, a1) {
|
|
if (!(a1 ? !a1 : this._threads.has(a0))) {
|
|
this._subscribed.delete(a0);
|
|
}
|
|
delete this._pending[a0];
|
|
this._members.clear(a0);
|
|
this._channels.clear(a0);
|
|
this._threadMemberLists.clear(a0);
|
|
this._typing.delete(a0);
|
|
this._memberUpdates.delete(a0);
|
|
if (a1) {
|
|
this._threads.delete(a0);
|
|
}
|
|
this._activities.delete(a0);
|
|
}
|
|
flush() {
|
|
Module12.forEach(this._pending, (a0, a1) => {
|
|
this._subscribed.add(a1);
|
|
});
|
|
this._onChange(this._pending);
|
|
this._pending = {};
|
|
}
|
|
subscribeUser(a0, a1) {
|
|
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
|
|
this._members.subscribe(a0, a1);
|
|
}
|
|
}
|
|
unsubscribeUser(a0, a1) {
|
|
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
|
|
this._members.unsubscribe(a0, a1);
|
|
}
|
|
}
|
|
subscribeChannel(a0, a1, a2) {
|
|
return !!(a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) && this._channels.subscribe(a0, a1, a2);
|
|
}
|
|
subscribeToMemberUpdates(a0) {
|
|
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
|
|
this._enqueue(a0, {
|
|
member_updates: true
|
|
});
|
|
this._memberUpdates.add(a0);
|
|
return void 0;
|
|
}
|
|
return false;
|
|
}
|
|
unsubscribeFromMemberUpdates(a0) {
|
|
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) {
|
|
this._enqueue(a0, {
|
|
member_updates: false
|
|
});
|
|
return void 0;
|
|
}
|
|
return false;
|
|
}
|
|
subscribeThreadMemberList(a0, a1, a2) {
|
|
return !!(a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) && this._threadMemberLists.subscribe(a0, a1, a2);
|
|
}
|
|
unsubscribeThreadMemberList(a0, a1) {
|
|
return !!(a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0)) && this._threadMemberLists.unsubscribe(a0, a1);
|
|
}
|
|
subscribeToGuild(a0) {
|
|
this._subscribeToFeature(a0, this._typing, {
|
|
typing: true
|
|
});
|
|
this._subscribeToFeature(a0, this._activities, {
|
|
activities: true
|
|
});
|
|
this._subscribeToFeature(a0, this._threads, {
|
|
threads: true
|
|
});
|
|
}
|
|
_subscribeToFeature(a0, a1, a2) {
|
|
if (a0 != null && a0 !== "null" && a0 !== ME && a0 !== "undefined" && !isFavoritesGuildId(a0) && !a1.has(a0)) {
|
|
a1.add(a0);
|
|
this._enqueue(a0, a2);
|
|
}
|
|
}
|
|
}
|
|
export default GuildSubscriptions;
|
|
export const MINIMUM_RANGE = _GuildChannelSubscriptions.MINIMUM_RANGE;
|
|
export const DEFAULT_RANGES = _GuildChannelSubscriptions.DEFAULT_RANGES;
|