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

59 lines
2.2 KiB
TypeScript

// Metro module 7727 (f7728).
import ChannelStore from "../../stores/ChannelStore";
import ChannelSpoilerAgreeStore from "./ChannelSpoilerAgreeStore";
import { useStateFromStores } from "../../_bundle/Module589";
const isChannelSpoilerGated = function isChannelSpoilerGated(a0, r6 = ChannelSpoilerAgreeStore, r7 = ChannelStore) {
if (r6 === void 0) {
r6 = ChannelSpoilerAgreeStore;
}
if (r7 === void 0) {
r7 = ChannelStore;
}
const r1 = a0 == null;
let r9 = null;
if (!r1) {
if (a0.isSpoilerChannel()) {
r9 = r6.didAgree(a0.id) ? null : a0.id;
} else {
const r12 = a0.parent_id != null;
r9 = null;
if (r12) {
const channel = r7.getChannel(a0.parent_id);
r9 = channel != null ? channel.isSpoilerChannel() ? r6.didAgree(channel.id) ? null : channel.id : null : null;
}
}
}
return r9 != null;
};
export function useGetSpoilerGatingChannelId(a0) {
return useStateFromStores([ChannelSpoilerAgreeStore, ChannelStore], () => {
if (ChannelSpoilerAgreeStore !== void 0 && ChannelStore !== void 0) {
const r9 = a0 == null;
let r10 = null;
if (!r9) {
if (a0.isSpoilerChannel()) {
r10 = ChannelSpoilerAgreeStore.didAgree(a0.id) ? null : a0.id;
} else {
const r13 = a0.parent_id != null;
r10 = null;
if (r13) {
const channel = ChannelStore.getChannel(a0.parent_id);
r10 = channel != null ? channel.isSpoilerChannel() ? ChannelSpoilerAgreeStore.didAgree(channel.id) ? null : channel.id : null : null;
}
}
}
return r10;
}
}, [a0]);
}
export { isChannelSpoilerGated };
export function useIsChannelSpoilerGated(a0) {
return useStateFromStores([ChannelSpoilerAgreeStore, ChannelStore], () => isChannelSpoilerGated(a0, ChannelSpoilerAgreeStore, ChannelStore), [a0]);
}
export function useShouldShowSpoilerGateForChannelId(a0) {
return useStateFromStores([ChannelStore, ChannelSpoilerAgreeStore], () => isChannelSpoilerGated(ChannelStore.getChannel(a0), ChannelSpoilerAgreeStore, ChannelStore), [a0]);
}
export function shouldShowSpoilerGateForChannelId(a0) {
return a0 != null && isChannelSpoilerGated(ChannelStore.getChannel(a0));
}