Files
discord-decomp/sources/modules/guild_scheduled_events/useGuildScheduledEvents.tsx
T
2026-07-28 01:06:53 +03:00

373 lines
22 KiB
TypeScript

/* Metro module 9127; source: modules/guild_scheduled_events/useGuildScheduledEvents.tsx; dependencies: [57, 31, 1379, 1867, 3784, 4117, 9128, 1385, 661, 672, 566, 9039, 9129, 9045, 2] */
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
import Durations from '../../utils/Durations.tsx'; /* Metro dependency 672 */
import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import PermissionStore from '../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */
import GuildScheduledEventStore from './GuildScheduledEventStore.tsx'; /* Metro dependency 4117 */
import UpcomingEventNoticesStore from './UpcomingEventNoticesStore.tsx'; /* Metro dependency 9128 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as GuildScheduledEventStoreModule from './GuildScheduledEventStore.tsx'; /* Metro dependency 4117 */
import * as UseEventScheduleModule from './useEventSchedule.tsx'; /* Metro dependency 9045 */
function _fun71494(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#71494, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:6, offset: 0x01d22bc8, size: 463 bytes, params: 8, frame: 20
let env0_0 = require;
const closure = function(a0) {
var env0_0 = a0;
return require(dependencyMap[10]).useStateFromStoresArray([GuildScheduledEventStore, ChannelStore,
PermissionStore],
_fun71496, [a0]);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = GuildScheduledEventStoreModule;
const env0_7 = value.isGuildScheduledEventActive;
const env0_8 = value.StaticGuildEventIndexes;
value = require(1385) /* metro dependency 1385: GuildScheduledEventsConstants */;
const env0_11 = value.GuildScheduledEventEntityTypes;
const env0_12 = value.GuildScheduledEventStatus;
value = require(661) /* metro dependency 661: Constants */;
const env0_13 = value.GuildFeatures;
const env0_14 = value.Permissions;
const env0_15 = [];
const Millis = (Durations).Millis;
const MINUTE = Millis.MINUTE;
const env0_16 = 15 * MINUTE;
(FileImportTrackerModule).fileFinishedImporting('modules/guild_scheduled_events/useGuildScheduledEvents.tsx');
exports.default = function(a0, a1) {
var env0_0 = a0;
var env0_1 = a1;
return require(dependencyMap[10]).useStateFromStoresArray([GuildStore, GuildScheduledEventStore,
PermissionStore,
ChannelStore], _fun71499, [a1, a0]);
};
exports.useActiveEvent = function(a0) {
var env0_0 = a0;
return require(dependencyMap[10]).useStateFromStores([GuildScheduledEventStore, ChannelStore, PermissionStore],
_fun71502, [a0]);
};
exports.useActiveEventsByChannel = useActiveEventsByChannel;
exports.useGuildUpcomingEvents = closure;
exports.useGuildUpcomingEventsNotice = useGuildUpcomingEventsNotice;
exports.useGuildActiveEvent = function(a0) {
var env0_0 = a0;
return require(dependencyMap[10]).useStateFromStores([GuildScheduledEventStore, ChannelStore, PermissionStore],
_fun71514, [a0]);
};
exports.useGuildChannelScheduledEvents = function(a0) {
var env0_0 = a0;
return require(dependencyMap[10]).useStateFromStores([GuildScheduledEventStore], _fun71517, [a0]);
};
exports.useFirstActiveEventChannel = function(a0) {
var env0_0 = a0;
return require(dependencyMap[10]).useStateFromStores([ChannelStore, GuildScheduledEventStore], _fun71519, [a0]);
};
exports.useImminentUpcomingGuildEvents = useImminentUpcomingGuildEvents;
function useGuildUpcomingEvents(a0) { // fn#71495, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:395, offset: 0x01d22d97, size: 92 bytes, params: 2, frame: 17
const env0_0 = a0;
return (FluxModule).useStateFromStoresArray([GuildScheduledEventStore,
ChannelStore, PermissionStore], _fun71496, [a0]);
function _fun71496() { // fn#71496, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:479, offset: 0x01d22df3, size: 61 bytes, params: 1, frame: 13
var environment;
const value = environment.__proto__;
const guildScheduledEventStoreBinding = GuildScheduledEventStore;
const getGuildScheduledEventsByIndex = guildScheduledEventStoreBinding.getGuildScheduledEventsByIndex;
const GUILD_EVENT_UPCOMING = StaticGuildEventIndexes.GUILD_EVENT_UPCOMING;
return Reflect.apply(getGuildScheduledEventsByIndex, guildScheduledEventStoreBinding,
[Reflect.apply(GUILD_EVENT_UPCOMING, StaticGuildEventIndexes, [env0_0])]).filter(function(a0) {
if (a0.entity_type === GuildScheduledEventEntityTypes.NONE) {
return false;
}
if (a0.status !== GuildScheduledEventStatus.SCHEDULED) {
return false;
}
if (a0.channel_id == null) {
return true;
}
return PermissionStore.can(Permissions.VIEW_CHANNEL, ChannelStore.getChannel(a0.channel_id));
});
}
}
function useGuildEvents(a0, a1) { // fn#71498, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:821, offset: 0x01d22e9f, size: 111 bytes, params: 3, frame: 18
const env0_0 = a0;
const env0_1 = a1;
return (FluxModule).useStateFromStoresArray([GuildStore,
GuildScheduledEventStore, PermissionStore, ChannelStore], _fun71499, [a1, a0]);
function _fun71499() { // fn#71499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:901, offset: 0x01d22f0e, size: 107 bytes, params: 1, frame: 15
var environment;
var r0;
var guildScheduledEventStoreBinding;
var getGuildScheduledEventsByIndex;
let value = environment.__proto__;
const guild = GuildStore.getGuild(env0_0);
if (guild == null) {
r0 = env1_15;
} else {
guildScheduledEventStoreBinding = GuildScheduledEventStore;
getGuildScheduledEventsByIndex = guildScheduledEventStoreBinding.getGuildScheduledEventsByIndex;
r0 = require ?? StaticGuildEventIndexes.GUILD_EVENT_UPCOMING(guild.id);
value = Reflect.apply(getGuildScheduledEventsByIndex, guildScheduledEventStoreBinding, [r0]);
value = value.filter(function({channel_id}) {
if (channel_id == null) {
return true;
}
return PermissionStore.can(Permissions.VIEW_CHANNEL, ChannelStore.getChannel(channel_id));
});
r0 = value;
}
return r0;
}
}
function useActiveEvent(a0) { // fn#71501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1150, offset: 0x01d22fb8, size: 91 bytes, params: 2, frame: 17
const env0_0 = a0;
return (FluxModule).useStateFromStores([GuildScheduledEventStore, ChannelStore,
PermissionStore], _fun71502, [a0]);
function _fun71502() { // fn#71502, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1221, offset: 0x01d23013, size: 133 bytes, params: 1, frame: 15
var guildScheduledEventStoreBinding;
let value = environment.__proto__;
const channel = ChannelStore.getChannel(env0_0);
const permissionStoreBinding = PermissionStore;
const can = permissionStoreBinding.can;
const VIEW_CHANNEL = Permissions.VIEW_CHANNEL;
const value4 = Reflect.apply(can, permissionStoreBinding, [VIEW_CHANNEL, channel]);
const value5 = null;
if (value4) {
if (value5 == (value5 == channel ? undefined : channel.guild_id)) {
return value5;
}
guildScheduledEventStoreBinding = GuildScheduledEventStore;
value = guildScheduledEventStoreBinding.getGuildScheduledEventsByIndex(StaticGuildEventIndexes.CHANNEL_EVENT_ACTIVE(env0_0));
return value.length > 0 ? value[0] : value5;
}
return value5;
}
}
function useActiveEventsByChannel(a0) { // fn#71503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1466, offset: 0x01d23098, size: 110 bytes, params: 2, frame: 17
const env0_0 = a0;
return ReactModule.useMemo(_fun71505,
[(FluxModule).useStateFromStoresArray([GuildScheduledEventStore], _fun71504,
[a0])]);
function _fun71504() { // fn#71504, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1547, offset: 0x01d23106, size: 27 bytes, params: 1, frame: 11
return GuildScheduledEventStore.getGuildScheduledEventsForGuild(env0_0);
}
function _fun71505() { // fn#71505, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1612, offset: 0x01d23121, size: 60 bytes, params: 1, frame: 12
const Map = global.Map;
const map = new Map();
env0_1.forEach(_fun71506);
return map;
function _fun71506(a0) { // fn#71506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1649, offset: 0x01d2315d, size: 36 bytes, params: 2, frame: 13
const channel_id = a0.channel_id;
if (channel_id != null) {
env0_0.set(channel_id, a0);
}
}
}
}
function useGuildUpcomingEventsNotice(a0) { // fn#71507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:1784, offset: 0x01d23181, size: 415 bytes, params: 2, frame: 26
var r5;
var r12;
var length;
var value9;
var property;
var id;
var property2;
var property3;
var property4;
var value10;
var moduleValue5;
var nextShownUpcomingEventNoticeType;
var value12;
const env0_0 = a0;
const value2 = useGuildUpcomingEvents(a0);
const useStateFromStoresObject = FluxModule.useStateFromStoresObject;
const upcomingEventNoticesStoreBinding = UpcomingEventNoticesStore;
const value3 = Reflect.apply(useStateFromStoresObject, FluxModule, [[upcomingEventNoticesStoreBinding], function() {
return UpcomingEventNoticesStore.getAllEventDismissals();
}]);
const value4 = FluxModule.useStateFromStoresObject([upcomingEventNoticesStoreBinding], function() {
return UpcomingEventNoticesStore.getAllUpcomingNoticeSeenTimes();
});
const value5 = FluxModule.useStateFromStoresObject([GuildScheduledEventStore], _fun71510, [value2]);
const guild = FluxModule.useStateFromStores([GuildStore], _fun71512);
if (value2 != null) {
if (value5 == null) {
return undefined;
}
if (guild != null && !guild.features.has(GuildFeatures.COMMUNITY) && guild.features.has(GuildFeatures.INTERNAL_EMPLOYEE_ONLY)) {
length = value2.length;
value9 = 0;
if (value9 < length) {
r5 = value9;
while (true) {
property = value2[r5];
id = property.id;
property2 = value3[id];
id = property.id;
property3 = value4[id];
id = property.id;
property4 = value5[id];
value10 = property4 != null;
r12 = value10 && property4;
moduleValue5 = require(9129) /* metro dependency 9129: GuildScheduledEventUtils */;
nextShownUpcomingEventNoticeType = moduleValue5.getNextShownUpcomingEventNoticeType(property,
property2,
property3,
r12);
if (nextShownUpcomingEventNoticeType != null) {
return {upcomingEvent: property, noticeType: nextShownUpcomingEventNoticeType};
}
value12 = typeof r5 === 'bigint' ? r5 + 1n : +r5 + 1;
length = value2.length;
if (value12 < length) {
r5 = value12;
continue;
}
break;
}
return undefined;
}
return undefined;
}
}
function _fun71510() { // fn#71510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:2052, offset: 0x01d2334a, size: 46 bytes, params: 1, frame: 13
return env0_1 == null ? {} : env0_1.reduce(function(a0, a1) {
var value2 = require(dependencyMap[11]).getNextRecurrenceIdInEvent(a1);
var object = {};
copyDataProperties(object, a0, value2);
object[a1.id] = GuildScheduledEventStore.isInterestedInEventRecurrence(a1.id, value2);
return object;
}, {});
}
function _fun71512() { // fn#71512, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:2237, offset: 0x01c7a19a, size: 27 bytes, params: 1, frame: 11
return GuildStore.getGuild(env0_0);
}
}
function useGuildActiveEvent(a0) { // fn#71513, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:2574, offset: 0x01d233cc, size: 91 bytes, params: 2, frame: 17
const env0_0 = a0;
return (FluxModule).useStateFromStores([GuildScheduledEventStore, ChannelStore,
PermissionStore], _fun71514, [a0]);
function _fun71514() { // fn#71514, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:2650, offset: 0x01d23427, size: 62 bytes, params: 1, frame: 13
var environment;
const value = environment.__proto__;
const guildScheduledEventStoreBinding = GuildScheduledEventStore;
const getGuildScheduledEventsByIndex = guildScheduledEventStoreBinding.getGuildScheduledEventsByIndex;
const GUILD_EVENT_ACTIVE = StaticGuildEventIndexes.GUILD_EVENT_ACTIVE;
return Reflect.apply(getGuildScheduledEventsByIndex, guildScheduledEventStoreBinding,
[Reflect.apply(GUILD_EVENT_ACTIVE, StaticGuildEventIndexes, [env0_0])]).find(function(a0) {
if (a0.entity_type !== GuildScheduledEventEntityTypes.NONE) {
if (isGuildScheduledEventActive(a0)) {
if (a0.channel_id == null) {
return true;
}
return PermissionStore.can(Permissions.VIEW_CHANNEL, ChannelStore.getChannel(a0.channel_id));
}
}
return false;
});
}
}
function useGuildChannelScheduledEvents(a0) { // fn#71516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:2902, offset: 0x01d234cf, size: 75 bytes, params: 2, frame: 16
const env0_0 = a0;
return (FluxModule).useStateFromStores([GuildScheduledEventStore], _fun71517,
[a0]);
function _fun71517() { // fn#71517, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:2985, offset: 0x01d2351a, size: 42 bytes, params: 1, frame: 13
const guildScheduledEventStoreBinding = GuildScheduledEventStore;
const getGuildScheduledEventsByIndex = guildScheduledEventStoreBinding.getGuildScheduledEventsByIndex;
const CHANNEL_EVENT_UPCOMING = StaticGuildEventIndexes.CHANNEL_EVENT_UPCOMING;
return Reflect.apply(getGuildScheduledEventsByIndex, guildScheduledEventStoreBinding,
[Reflect.apply(CHANNEL_EVENT_UPCOMING, StaticGuildEventIndexes, [env0_0])]);
}
}
function useFirstActiveEventChannel(a0) { // fn#71518, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3087, offset: 0x01d23544, size: 83 bytes, params: 2, frame: 17
const env0_0 = a0;
return (FluxModule).useStateFromStores([ChannelStore, GuildScheduledEventStore],
_fun71519, [a0]);
function _fun71519() { // fn#71519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3168, offset: 0x01d23597, size: 92 bytes, params: 1, frame: 14
var environment;
const value = environment.__proto__;
const guildScheduledEventStoreBinding = GuildScheduledEventStore;
const getGuildScheduledEventsByIndex = guildScheduledEventStoreBinding.getGuildScheduledEventsByIndex;
const GUILD_EVENT_ACTIVE = StaticGuildEventIndexes.GUILD_EVENT_ACTIVE;
return ChannelStore.getChannel(Reflect.apply(getGuildScheduledEventsByIndex, guildScheduledEventStoreBinding,
[Reflect.apply(GUILD_EVENT_ACTIVE, StaticGuildEventIndexes, [env0_0])]).find(_fun71520)?.channel_id);
function _fun71520({channel_id}) { // fn#71520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3243, offset: 0x01d235f3, size: 33 bytes, params: 2, frame: 11
const value = environment.__proto__.__proto__;
return ChannelStore.getChannel(channel_id) != null;
}
}
}
function useImminentUpcomingGuildEvents(a0) { // fn#71521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3371, offset: 0x01d23614, size: 182 bytes, params: 2, frame: 19
const env0_0 = a0;
const [property, env0_1] = Module00057(ReactModule.useState(function() {
var Date = global.Date;
return Date.now();
}), 2);
ReactModule.useEffect(_fun71523, []);
return ReactModule.useMemo(_fun71527,
[(FluxModule).useStateFromStores([GuildScheduledEventStore], _fun71526, [a0,
property])]);
function _fun71523() { // fn#71523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3485, offset: 0x01d236ca, size: 45 bytes, params: 1, frame: 14
const env0_0 = global.setInterval(_fun71524, env1_16);
return _fun71525;
function _fun71524() { // fn#71524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3509, offset: 0x01d236f7, size: 33 bytes, params: 1, frame: 11
const value = environment.__proto__;
const binding = env1_1;
const Date = global.Date;
binding(Date.now());
}
function _fun71525() { // fn#71525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3539, offset: 0x013378b1, size: 24 bytes, params: 1, frame: 11
return global.clearInterval(env0_0);
}
}
function _fun71526() { // fn#71526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3605, offset: 0x01d23718, size: 58 bytes, params: 1, frame: 13
return env0_0 == null ? [] : GuildScheduledEventStore.getGuildScheduledEventsByIndex(StaticGuildEventIndexes.CHANNEL_EVENT_UPCOMING(env0_0));
}
function _fun71527() { // fn#71527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3708, offset: 0x01d23752, size: 28 bytes, params: 1, frame: 11
return Module00057.filter(_fun71528);
function _fun71528(a0) { // fn#71528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9312:3722, offset: 0x01d2376e, size: 153 bytes, params: 2, frame: 17
const value = environment.__proto__.__proto__;
const value2 = undefined;
const {startTime, endTime} = (UseEventScheduleModule).getEventSchedule(a0);
const {withinStartWindow,
diffMinutes} = (require(9039) /* metro dependency 9039: ScheduleUtils */).getEventTimeData(startTime.toISOString(),
endTime == null ? value2 : endTime.toISOString());
const status = a0.status;
const ACTIVE = GuildScheduledEventStatus.ACTIVE;
return status !== ACTIVE && withinStartWindow && diffMinutes < 15;
}
}
}
}
global.__d(_fun71494, 9127, [57, 31, 1379, 1867, 3784, 4117, 9128, 1385, 661, 672, 566, 9039, 9129, 9045,
2]) /* metro module 9127, dependencies: [57, 31, 1379, 1867, 3784, 4117, 9128, 1385, 661, 672, 566, 9039, 9129, 9045, 2] */;