66 lines
4.3 KiB
TypeScript
66 lines
4.3 KiB
TypeScript
// Metro module 15154 (f15155).
|
|
import { useMemo } from "react";
|
|
import StageChannelParticipantStore from "../stage_channels/StageChannelParticipantStore";
|
|
import StageInstanceStore from "../stage_channels/StageInstanceStore";
|
|
import ApplicationStreamingStore from "../../stores/ApplicationStreamingStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import SortedVoiceStateStore from "../../stores/views/SortedVoiceStateStore";
|
|
import LiveChannelNoticesStore from "./LiveChannelNoticesStore";
|
|
import { GuildScheduledEventEntityTypes } from "./GuildScheduledEventsConstants";
|
|
import { Permissions } from "../../_bundle/Module505";
|
|
import useLiveStageChannels from "../stage_channels/useLiveStageChannels";
|
|
import { useStateFromStores, useStateFromStoresObject } from "../../_bundle/Module589";
|
|
import { useGuildActiveEvent } from "./useGuildScheduledEvents";
|
|
import { useActiveEventOrStageInstanceChannel } from "./useActiveEventOrStageInstanceChannel";
|
|
import { useActualStageSpeakerCount } from "../stage_channels/StageChannelParticipantStoreHooks";
|
|
import { StageChannelParticipantNamedIndex } from "../stage_channels/StageChannelParticipants";
|
|
export function useGuildHasLiveChannelNotice(a0) {
|
|
const id = useLiveStageChannels(a0)[0]?.id;
|
|
let guildActiveEvent;
|
|
const channel = ChannelStore.getChannel(id);
|
|
const stateFromStores = useStateFromStores([StageInstanceStore], () => StageInstanceStore.getStageInstanceByChannel(channel?.id), [channel]);
|
|
guildActiveEvent = useGuildActiveEvent(a0);
|
|
const stateFromStoresObject = useStateFromStoresObject([LiveChannelNoticesStore], () => ({
|
|
isStageNoticeHidden: LiveChannelNoticesStore.isLiveChannelNoticeHidden({
|
|
stageId: stateFromStores?.id
|
|
}),
|
|
isEventNoticeHidden: LiveChannelNoticesStore.isLiveChannelNoticeHidden({
|
|
eventId: guildActiveEvent?.id
|
|
})
|
|
}), [stateFromStores, guildActiveEvent]);
|
|
const { isStageNoticeHidden, isEventNoticeHidden } = stateFromStoresObject;
|
|
return guildActiveEvent != null ? stateFromStores != null ? !isStageNoticeHidden : !isEventNoticeHidden : stateFromStores != null && !isStageNoticeHidden;
|
|
}
|
|
export function useGuildLiveChannelNoticeInfo(a0) {
|
|
let r48;
|
|
let stateFromStores3, stateFromStores4, stateFromStores5, entity_type;
|
|
const activeEventOrStageInstanceChannel = useActiveEventOrStageInstanceChannel(a0);
|
|
const stateFromStores2 = useStateFromStores([PermissionStore], () => activeEventOrStageInstanceChannel != null && PermissionStore.can(Permissions.CONNECT, activeEventOrStageInstanceChannel));
|
|
const guildActiveEvent2 = useGuildActiveEvent(a0);
|
|
const stateFromStores6 = useStateFromStores([StageInstanceStore], () => StageInstanceStore.getStageInstanceByChannel(activeEventOrStageInstanceChannel?.id), [activeEventOrStageInstanceChannel]);
|
|
const r39 = useActualStageSpeakerCount(activeEventOrStageInstanceChannel?.id) > 0;
|
|
const stateFromStores7 = useStateFromStores([SortedVoiceStateStore], () => activeEventOrStageInstanceChannel != null && SortedVoiceStateStore.getVoiceStatesForChannel(activeEventOrStageInstanceChannel).length > 0);
|
|
stateFromStores3 = false;
|
|
if (activeEventOrStageInstanceChannel != null && stateFromStores6 != null) {
|
|
stateFromStores3 = r39;
|
|
r48 = r39;
|
|
} else {
|
|
const r2 = activeEventOrStageInstanceChannel != null && guildActiveEvent2 != null;
|
|
r48 = false;
|
|
if (r2) {
|
|
stateFromStores3 = stateFromStores7;
|
|
r48 = stateFromStores7;
|
|
}
|
|
}
|
|
stateFromStores4 = useStateFromStores([StageChannelParticipantStore], () => activeEventOrStageInstanceChannel != null && StageChannelParticipantStore.getParticipantCount(activeEventOrStageInstanceChannel.id, StageChannelParticipantNamedIndex.AUDIENCE) > 0, [activeEventOrStageInstanceChannel]);
|
|
stateFromStores5 = useStateFromStores([ApplicationStreamingStore], () => activeEventOrStageInstanceChannel != null && ApplicationStreamingStore.getAllApplicationStreamsForChannel(activeEventOrStageInstanceChannel.id).length > 0);
|
|
entity_type = guildActiveEvent2?.entity_type;
|
|
return useMemo(() => ({
|
|
hasButton: entity_type === GuildScheduledEventEntityTypes.EXTERNAL || stateFromStores2,
|
|
hasSpeakers: stateFromStores3,
|
|
hasAudience: stateFromStores4,
|
|
hasStream: stateFromStores5
|
|
}), [stateFromStores2, entity_type, r48, stateFromStores4, stateFromStores5]);
|
|
}
|