Files
discord-decomp/modules/guild_scheduled_events/utils/GuildEventRsvpUtils.tsx
T
2026-11-01 12:12:55 +02:00

68 lines
2.6 KiB
TypeScript

// Metro module 8214 (f8215).
import AuthenticationStore from "../../../stores/AuthenticationStore";
import GuildScheduledEventStore from "../GuildScheduledEventStore";
import { GuildScheduledEventStatusDone, GuildScheduledEventUserResponses } from "../GuildScheduledEventsConstants";
import { intl, t } from "../../../intl/index.native";
import { getEventException } from "../useEventException";
import { getEventSchedule } from "../useEventSchedule";
import { getRecurrenceStatus, getNextRecurrenceIdInEvent } from "./ScheduleUtils";
let c5220_6 = {
SERIES: 0,
0: "SERIES",
RECURRENCE: 1,
1: "RECURRENCE"
};
export function getExistingRsvp(a0, a1) {
return GuildScheduledEventStore.getRsvp(a0, a1, AuthenticationStore.getId());
}
export { c5220_6 as ResponseOptions };
export function getResponseOptions() {
return [{
name: intl.string(t.uoorxi),
value: c5220_6.SERIES
}, {
name: intl.string(t.lwZCFT),
value: c5220_6.RECURRENCE
}];
}
export function handleRsvp(a0) {
let r46;
const eventId = a0.eventId;
let recurrenceId = a0.recurrenceId;
const { guildId, updateRsvp, openRsvpPicker, onRsvp } = a0;
const guildScheduledEvent = GuildScheduledEventStore.getGuildScheduledEvent(eventId);
if (guildScheduledEvent != null) {
const eventException = getEventException(recurrenceId, eventId);
const startTime = getEventSchedule(guildScheduledEvent, recurrenceId).startTime;
const r16 = guildScheduledEvent?.scheduled_start_time != null ? getRecurrenceStatus(eventException, startTime, new Date(guildScheduledEvent?.scheduled_start_time)) : null;
L12: {
if (r16 != null) {
const r45 = GuildScheduledEventStatusDone.has(r16);
r46 = null;
if (r45) {
break L12;
}
}
if (recurrenceId == null) {
recurrenceId = getNextRecurrenceIdInEvent(guildScheduledEvent);
}
r46 = recurrenceId;
}
const rsvp = GuildScheduledEventStore.getRsvp(guildScheduledEvent.id, void 0, AuthenticationStore.getId());
const rsvp2 = GuildScheduledEventStore.getRsvp(guildScheduledEvent.id, r46, AuthenticationStore.getId());
if (r46 == null) {
updateRsvp(eventId, null, guildId, rsvp != null ? GuildScheduledEventUserResponses.UNINTERESTED : GuildScheduledEventUserResponses.INTERESTED);
if (onRsvp != null) {
onRsvp();
}
} else if (rsvp2 != null) {
updateRsvp(eventId, r46, guildId, rsvp != null ? GuildScheduledEventUserResponses.INTERESTED : GuildScheduledEventUserResponses.UNINTERESTED);
if (onRsvp != null) {
onRsvp();
}
} else {
openRsvpPicker(guildScheduledEvent, r46);
}
}
}