211 lines
6.3 KiB
TypeScript
211 lines
6.3 KiB
TypeScript
// Metro module 8209 (f8210).
|
|
import AuthenticationStore from "../../../stores/AuthenticationStore";
|
|
import { FAKE_EVENT_ID, GuildScheduledEventEntityTypes, GuildScheduledEventPrivacyLevel, GuildScheduledEventStatus } from "../GuildScheduledEventsConstants";
|
|
import { getInitialEventStartDate } from "./ScheduleUtils";
|
|
import { getLocationFromEvent } from "./EntityUtils";
|
|
const r20 = {
|
|
CHANNEL_SELECTOR: "ChannelSelector",
|
|
DETAILS: "Details",
|
|
PREVIEW: "Preview"
|
|
};
|
|
export { r20 as EditGuildEventScreens };
|
|
export function isEditingEvent(a0) {
|
|
return Boolean(a0?.id);
|
|
}
|
|
export function recurrenceRuleToServer(a0) {
|
|
const r1 = a0 == null;
|
|
let r2 = null;
|
|
if (!r1) {
|
|
let r15 = a0.byMonthDay?.length;
|
|
if (r15 == null) {
|
|
r15 = 0;
|
|
}
|
|
r2 = {
|
|
start: a0.start,
|
|
end: a0.end,
|
|
frequency: a0.frequency,
|
|
interval: a0.interval,
|
|
by_weekday: a0.byWeekday,
|
|
by_n_weekday: a0.byNWeekday,
|
|
by_month: a0.byMonth,
|
|
by_month_day: r15 > 0 ? a0.byMonthDay : null,
|
|
by_year_day: a0.byYearDay,
|
|
count: a0.count
|
|
};
|
|
}
|
|
return r2;
|
|
}
|
|
export function recurrenceRuleFromServer(a0) {
|
|
return a0 == null ? null : {
|
|
start: new Date(a0.start).toISOString(),
|
|
end: a0.end != null ? new Date(a0.end).toISOString() : null,
|
|
frequency: a0.frequency,
|
|
interval: a0.interval,
|
|
byWeekday: a0.by_weekday,
|
|
byNWeekday: a0.by_n_weekday,
|
|
byMonth: a0.by_month,
|
|
byMonthDay: a0.by_month_day,
|
|
byYearDay: a0.by_year_day,
|
|
count: a0.count
|
|
};
|
|
}
|
|
export function isExistingGuildEvent(a0) {
|
|
return a0 != null && "id" in a0;
|
|
}
|
|
export function convertToFakeGuildEvent(a0, a1, a2) {
|
|
let id = a2;
|
|
const name = a0.name;
|
|
let description = a0.description;
|
|
const { privacyLevel, channelId, scheduledStartTime, scheduledEndTime, entityType } = a0;
|
|
let entityMetadata = a0.entityMetadata;
|
|
let image = a0.image;
|
|
const { recurrenceRule, eventExceptions } = a0;
|
|
if (a2 == null) {
|
|
id = FAKE_EVENT_ID;
|
|
}
|
|
if (description == null) {
|
|
description = null;
|
|
}
|
|
if (entityMetadata == null) {
|
|
entityMetadata = null;
|
|
}
|
|
if (image == null) {
|
|
image = void 0;
|
|
}
|
|
const r17 = {
|
|
id,
|
|
name,
|
|
description,
|
|
privacy_level: privacyLevel,
|
|
scheduled_start_time: scheduledStartTime,
|
|
scheduled_end_time: scheduledEndTime,
|
|
entity_type: entityType,
|
|
entity_metadata: entityMetadata,
|
|
image,
|
|
channel_id: channelId,
|
|
guild_id: a1,
|
|
creator_id: AuthenticationStore.getId(),
|
|
status: GuildScheduledEventStatus.SCHEDULED,
|
|
recurrence_rule: null,
|
|
guild_scheduled_event_exceptions: null
|
|
};
|
|
const r1 = recurrenceRule == null;
|
|
let recurrence_rule = null;
|
|
if (!r1) {
|
|
let r35 = recurrenceRule.byMonthDay?.length;
|
|
if (r35 == null) {
|
|
r35 = 0;
|
|
}
|
|
recurrence_rule = {
|
|
start: recurrenceRule.start,
|
|
end: recurrenceRule.end,
|
|
frequency: recurrenceRule.frequency,
|
|
interval: recurrenceRule.interval,
|
|
by_weekday: recurrenceRule.byWeekday,
|
|
by_n_weekday: recurrenceRule.byNWeekday,
|
|
by_month: recurrenceRule.byMonth,
|
|
by_month_day: r35 > 0 ? recurrenceRule.byMonthDay : null,
|
|
by_year_day: recurrenceRule.byYearDay,
|
|
count: recurrenceRule.count
|
|
};
|
|
}
|
|
r17.recurrence_rule = recurrence_rule;
|
|
r17.guild_scheduled_event_exceptions = eventExceptions.map((eventException) => ({
|
|
event_exception_id: eventException.eventExceptionId,
|
|
event_id: eventException.eventId,
|
|
guild_id: eventException.guildId,
|
|
scheduled_start_time: eventException.scheduledStartTime,
|
|
scheduled_end_time: eventException.scheduledEndTime,
|
|
is_canceled: eventException.isCanceled
|
|
}));
|
|
return r17;
|
|
}
|
|
export function getInitialGuildEventData(a0, a1) {
|
|
let name = a0?.name;
|
|
if (name == null) {
|
|
name = "";
|
|
}
|
|
let privacyLevel = a0?.privacy_level;
|
|
if (privacyLevel == null) {
|
|
privacyLevel = GuildScheduledEventPrivacyLevel.GUILD_ONLY;
|
|
}
|
|
let description = a0?.description;
|
|
if (description == null) {
|
|
description = "";
|
|
}
|
|
let scheduledStartTime = a0?.scheduled_start_time;
|
|
if (scheduledStartTime == null) {
|
|
scheduledStartTime = getInitialEventStartDate().toISOString();
|
|
}
|
|
let entityType = a0?.entity_type;
|
|
if (entityType == null) {
|
|
entityType = GuildScheduledEventEntityTypes.NONE;
|
|
}
|
|
let entityMetadata = a0?.entity_metadata;
|
|
if (entityMetadata == null) {
|
|
entityMetadata = void 0;
|
|
}
|
|
const channel_id = a0?.channel_id;
|
|
const creator_id = a0?.creator_id;
|
|
const image = a0?.image;
|
|
const scheduled_end_time = a0?.scheduled_end_time;
|
|
const recurrence_rule = a0?.recurrence_rule;
|
|
const recurrenceRule = recurrence_rule == null ? null : {
|
|
start: new Date(recurrence_rule.start).toISOString(),
|
|
end: recurrence_rule.end != null ? new Date(recurrence_rule.end).toISOString() : null,
|
|
frequency: recurrence_rule.frequency,
|
|
interval: recurrence_rule.interval,
|
|
byWeekday: recurrence_rule.by_weekday,
|
|
byNWeekday: recurrence_rule.by_n_weekday,
|
|
byMonth: recurrence_rule.by_month,
|
|
byMonthDay: recurrence_rule.by_month_day,
|
|
byYearDay: recurrence_rule.by_year_day,
|
|
count: recurrence_rule.count
|
|
};
|
|
let r68 = a0?.guild_scheduled_event_exceptions;
|
|
if (r68 == null) {
|
|
r68 = [];
|
|
}
|
|
const r4 = {
|
|
name,
|
|
privacyLevel,
|
|
description,
|
|
scheduledStartTime,
|
|
entityType,
|
|
entityMetadata,
|
|
channelId: channel_id,
|
|
creatorId: creator_id,
|
|
image,
|
|
scheduledEndTime: scheduled_end_time,
|
|
recurrenceRule,
|
|
eventExceptions: r68.map((item) => ({
|
|
eventExceptionId: item.event_exception_id,
|
|
eventId: item.event_id,
|
|
guildId: item.guild_id,
|
|
scheduledStartTime: item.scheduled_start_time,
|
|
scheduledEndTime: item.scheduled_end_time,
|
|
isCanceled: item.is_canceled
|
|
}))
|
|
};
|
|
const r72 = a0 != null && "id" in a0;
|
|
L57: {
|
|
if (r72 && a0?.entity_type === GuildScheduledEventEntityTypes.EXTERNAL) {
|
|
const locationFromEvent = getLocationFromEvent(a0);
|
|
if (locationFromEvent == null) {
|
|
break L57;
|
|
}
|
|
r4.entityMetadata = {
|
|
location: locationFromEvent
|
|
};
|
|
} else if (r4.channelId == null && a1 != null) {
|
|
r4.channelId = a1.id;
|
|
if (a1.isGuildStageVoice()) {
|
|
r4.entityType = GuildScheduledEventEntityTypes.STAGE_INSTANCE;
|
|
} else if (a1.isGuildVoice()) {
|
|
r4.entityType = GuildScheduledEventEntityTypes.VOICE;
|
|
}
|
|
}
|
|
}
|
|
return r4;
|
|
}
|