81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
// Metro module 9507 (f9508).
|
|
import { isGuildNSFW } from "../records/GuildRecord";
|
|
import GuildStore from "../stores/GuildStore";
|
|
import { ChannelTypesSets, EMPTY_STRING_SNOWFLAKE_ID, GuildFeatures, ME } from "../Constants";
|
|
import { ChannelFlags } from "../modules/channel/ChannelConstants";
|
|
import { isFavoritesGuildId } from "../modules/favorites/FavoritesUtils";
|
|
import { useStateFromStores } from "../_bundle/defaultAreStatesEqual";
|
|
const canSeeChannelSummaries = function canSeeChannelSummaries(a0, r7 = false, r14 = true) {
|
|
let r5 = a0 != null;
|
|
if (r5) {
|
|
const r0 = a0 == null;
|
|
let r6 = false;
|
|
if (!r0) {
|
|
let r9 = a0?.guild_id;
|
|
if (r9 == null) {
|
|
r9 = "";
|
|
}
|
|
const guild = GuildStore.getGuild(r9);
|
|
const r19 = guild != null && guild.rulesChannelId === a0.id;
|
|
const isGuildNSFW2 = isGuildNSFW(guild);
|
|
r6 = ChannelTypesSets.SUMMARIZEABLE.has(a0.type) && !a0.isNSFW() && !r19 && !isGuildNSFW2;
|
|
}
|
|
let r31 = !!r6;
|
|
if (r31) {
|
|
let r32 = r7 !== false || !a0.hasFlag(ChannelFlags.SUMMARIES_DISABLED);
|
|
if (r32) {
|
|
const guild2 = GuildStore.getGuild(a0.guild_id);
|
|
if (r14 === void 0) {
|
|
r14 = true;
|
|
}
|
|
let r41 = guild2 != null;
|
|
if (r41) {
|
|
const id = guild2.id;
|
|
const r42 = id != null && (id === ME || isFavoritesGuildId(id));
|
|
r41 = r42 ? !r42 : !!guild2.features.has(GuildFeatures.SUMMARIES_ENABLED_GA) && (r14 ? guild2.features.has(GuildFeatures.SUMMARIES_ENABLED_BY_USER) : !r14);
|
|
}
|
|
r32 = r41;
|
|
}
|
|
r31 = r32;
|
|
}
|
|
r5 = r31;
|
|
}
|
|
return r5;
|
|
};
|
|
export function channelEligibleForSummaries(a0) {
|
|
return canSeeChannelSummaries(a0, true, false);
|
|
}
|
|
export { canSeeChannelSummaries };
|
|
export function canGuildUseConversationSummaries(a0, r8 = true) {
|
|
let r2 = a0 != null;
|
|
if (r2) {
|
|
const id = a0.id;
|
|
const r5 = id != null && (id === ME || isFavoritesGuildId(id));
|
|
r2 = r5 ? !r5 : !!a0.features.has(GuildFeatures.SUMMARIES_ENABLED_GA) && (r8 ? a0.features.has(GuildFeatures.SUMMARIES_ENABLED_BY_USER) : !r8);
|
|
}
|
|
return r2;
|
|
}
|
|
export function useChannelSummariesExperiment(a0) {
|
|
let r4 = arguments[2];
|
|
if (r4 === void 0) {
|
|
r4 = false;
|
|
}
|
|
return canSeeChannelSummaries(a0, r4);
|
|
}
|
|
export function useGuildEligibleForSummaries(a0) {
|
|
return useStateFromStores([GuildStore], () => {
|
|
let r11 = a0?.id;
|
|
if (r11 == null) {
|
|
r11 = EMPTY_STRING_SNOWFLAKE_ID;
|
|
}
|
|
const guild = GuildStore.getGuild(r11);
|
|
let r12 = guild != null;
|
|
if (r12) {
|
|
const id = guild.id;
|
|
const r13 = id != null && (id === ME || isFavoritesGuildId(id));
|
|
r12 = r13 ? !r13 : !!guild.features.has(GuildFeatures.SUMMARIES_ENABLED_GA) && !false;
|
|
}
|
|
return r12;
|
|
}, [a0]);
|
|
}
|