Files
discord-decomp/modules/guild_home/useActiveChannels.tsx
T
2026-11-01 12:12:55 +02:00

79 lines
2.7 KiB
TypeScript

// Metro module 15061 (f15062).
import { isTextChannel } from "../../records/ChannelRecord";
import ChannelStore from "../../stores/ChannelStore";
import PermissionStore from "../../stores/PermissionStore";
import UserGuildSettingsStore from "../../stores/UserGuildSettingsStore";
import ActiveChannelsStore from "./ActiveChannelsStore";
import { Permissions } from "../../Constants";
import { ChannelFlags } from "../channel/ChannelConstants";
import { isNotNullish } from "../../utils/GlobalUtils";
export function getActiveTextChannels(a0, r3 = [ChannelStore, PermissionStore, ActiveChannelsStore, UserGuildSettingsStore]) {
let r21, r22, r23, r24;
let r29 = r3[Symbol.iterator]();
const next = r29.next;
const r32 = r29 === void 0 ? void 0 : (r21 = next.call(r29)).done ? r29 = void 0 : r21.value;
let r0 = r29 === void 0;
const r33 = r0 ? void 0 : r32;
let c21632_0 = r33;
let r35 = void 0;
if (!r0) {
const r36 = r29 === void 0 ? void 0 : (r22 = next.call(r29)).done ? r29 = void 0 : r22.value;
const r2 = r29 === void 0;
r35 = void 0;
r0 = r2;
if (!r2) {
r35 = r36;
r0 = r2;
}
}
let c21632_1 = r35;
let r37 = void 0;
if (!r0) {
const r39 = r29 === void 0 ? void 0 : (r23 = next.call(r29)).done ? r29 = void 0 : r23.value;
const r41 = r29 === void 0;
r37 = void 0;
r0 = r41;
if (!r41) {
r37 = r39;
r0 = r41;
}
}
let r42 = void 0;
if (!r0) {
const r43 = r29 === void 0 ? void 0 : (r24 = next.call(r29)).done ? r29 = void 0 : r24.value;
const r45 = r29 === void 0;
r42 = void 0;
r0 = r45;
if (!r45) {
r42 = r43;
r0 = r45;
}
}
if (!r0 && r29 !== void 0 && typeof r29.return === "function") {
r29.return();
}
const activeChannelIds = r37.getActiveChannelIds(a0);
const r49 = activeChannelIds != null ? Array.from(activeChannelIds) : [];
const mutedChannels = r42.getMutedChannels(a0);
return r49.map((item) => c21632_0.getChannel(item)).filter(isNotNullish).filter((item) => {
if (item == null ? void 0 : item.hasFlag(ChannelFlags.ACTIVE_CHANNELS_REMOVED)) {
return false;
}
if (isTextChannel(item.type)) {
if (mutedChannels.has(item.id)) {
return false;
}
if (item.parent_id != null && mutedChannels.has(item.parent_id)) {
return false;
}
if (c21632_1.can(Permissions.VIEW_CHANNEL, item)) {
const channel = c21632_0.getChannel(item.parent_id);
const isThread = item.isThread();
return (isThread ? channel == null : !isThread) || !(channel == null ? void 0 : channel.hasFlag(ChannelFlags.ACTIVE_CHANNELS_REMOVED));
}
return false;
}
return false;
});
}