164 lines
7.3 KiB
TypeScript
164 lines
7.3 KiB
TypeScript
// Metro module 15386 (f15387).
|
|
import { useMemo, useCallback } from "react";
|
|
import { Pressable, View } from "react-native";
|
|
import GuildScheduledEventStore, { isGuildEventEnded, isGuildScheduledEventActive } from "../../guild_scheduled_events/GuildScheduledEventStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import { createICYMIStyles } from "./createICYMIStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import useEventSchedule from "../../guild_scheduled_events/useEventSchedule";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { getEventTimeData, getNextRecurrenceIdInEvent } from "../../guild_scheduled_events/utils/ScheduleUtils";
|
|
import useChannelName from "../../channel/useChannelName";
|
|
import { getLocationFromEvent } from "../../guild_scheduled_events/utils/EntityUtils";
|
|
import { getEventLocationIconSource, getEventLocationIconComponent } from "../../guild_scheduled_events/native/components/GuildEventUtils";
|
|
import ICYMIActionCreators from "../ICYMIActionCreators";
|
|
import { openGuildEventDetails } from "../../guild_scheduled_events/GuildScheduledEventModalActionCreators.native";
|
|
import { transitionToGuild } from "../../routing/transitionToGuild.native";
|
|
import useGuildScheduledEventUserCount from "../../guild_scheduled_events/useGuildScheduledEventUserCount";
|
|
import ICYMICardInCard from "./ICYMICardInCard";
|
|
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { guildEventDetailsParser } from "../../guild_scheduled_events/guildEventDetailsParser.native";
|
|
import { GroupIcon } from "../../../design/components/Icon/native/redesign/generated/GroupIcon";
|
|
import { Icon } from "../../../design/void/native";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
let styles;
|
|
const ICYMIGuildEventRow = function ICYMIGuildEventRow(props) {
|
|
const { event, channel, guild } = props;
|
|
const r22 = styles();
|
|
const eventSchedule = useEventSchedule(event, null);
|
|
const isGuildScheduledEventActive2 = isGuildScheduledEventActive(event);
|
|
const r33 = eventSchedule == null ? void 0 : eventSchedule.startTime.toISOString();
|
|
let c21944_3 = r33;
|
|
const startDateTimeString = useMemo(() => isGuildScheduledEventActive2 ? {
|
|
startDateTimeString: intl.string(t.TxqPQR)
|
|
} : getEventTimeData(c21944_3), [r33, isGuildScheduledEventActive2]).startDateTimeString;
|
|
let r21 = useChannelName(channel);
|
|
const locationFromEvent = getLocationFromEvent(event);
|
|
if (r21 == null) {
|
|
r21 = locationFromEvent;
|
|
}
|
|
const eventLocationIconSource = getEventLocationIconSource(event, channel, true);
|
|
const EventLocationIconComponent = getEventLocationIconComponent(event, channel, true);
|
|
const nextRecurrenceIdInEvent = getNextRecurrenceIdInEvent(event);
|
|
const callback = useCallback(() => {
|
|
ICYMIActionCreators.itemInteracted(event.id, "guild_event", "press_event");
|
|
ICYMIActionCreators.feedItemActioned({
|
|
itemId: event.id,
|
|
itemType: "guild_event",
|
|
actionParameters: {
|
|
actionGestureType: "press",
|
|
actionTargetElement: "item_body",
|
|
actionIntentType: "navigate",
|
|
actionDestinationType: "event"
|
|
}
|
|
});
|
|
openGuildEventDetails({
|
|
eventId: event.id,
|
|
event
|
|
});
|
|
}, [event]);
|
|
const callback2 = useCallback(() => {
|
|
ICYMIActionCreators.itemInteracted(event.id, "guild_event", "press_event");
|
|
ICYMIActionCreators.feedItemActioned({
|
|
itemId: event.id,
|
|
itemType: "guild_event",
|
|
actionParameters: {
|
|
actionGestureType: "press",
|
|
actionTargetElement: "item_header",
|
|
actionIntentType: "navigate",
|
|
actionDestinationType: "guild"
|
|
}
|
|
});
|
|
transitionToGuild(guild.id);
|
|
}, [guild.id, event.id]);
|
|
let style = event.description != null && event.description.length > 0;
|
|
const guildScheduledEventUserCount = useGuildScheduledEventUserCount(event?.guild_id, event?.id, nextRecurrenceIdInEvent);
|
|
const props2 = {
|
|
actionLabel: intl.string(t["6pFsLQ"]),
|
|
id: event.id,
|
|
interactionType: "guild_event",
|
|
channelId: channel?.id,
|
|
guildId: guild.id,
|
|
timestamp: SnowflakeUtils.extractTimestamp(event.id),
|
|
onHeaderPress: callback2,
|
|
onHeaderLongPress: callback2,
|
|
children: null
|
|
};
|
|
const r107 = [<View style={r22.timeAndUserPillContainer}>
|
|
<Text variant="text-sm/semibold" color={isGuildScheduledEventActive2 ? "status-positive" : "text-brand"}>{startDateTimeString}</Text>
|
|
</View>, , , , ,];
|
|
if (style) {
|
|
style = r22.title;
|
|
}
|
|
r107[1] = <Text style={style} variant="text-lg/semibold">{event.name}</Text>;
|
|
r107[2] = event.description != null && event.description.length > 0 && <Text variant="text-md/normal" color="text-subtle" lineClamp={5}>
|
|
{guildEventDetailsParser(event.description, true, {
|
|
guildId: guild.id
|
|
})}
|
|
</Text>;
|
|
r107[3] = <View style={r22.separator} />;
|
|
r107[4] = <View style={r22.infoContainer}>
|
|
<View style={r22.locationContainer}>
|
|
<GroupIcon size="xs" style={r22.eventsChannelIcon} />
|
|
<Text lineClamp={1} variant="text-xs/normal" color="text-muted">
|
|
{intl.format(t["+DLsD8"], {
|
|
count: guildScheduledEventUserCount
|
|
})}
|
|
</Text>
|
|
</View>
|
|
<View style={r22.locationContainer}>
|
|
{EventLocationIconComponent != null ? <EventLocationIconComponent size="xs" style={r22.eventsChannelIcon} /> : eventLocationIconSource != null && <Icon source={eventLocationIconSource} size={Icon.Sizes.EXTRA_SMALL} style={r22.eventsChannelIcon} disableColor />}
|
|
<Text lineClamp={2} variant="text-xs/normal" color="text-muted">
|
|
{r21 != null ? guildEventDetailsParser(r21, true) : null}
|
|
</Text>
|
|
</View>
|
|
</View>;
|
|
props2.children = <Pressable onPress={callback} style={r22.container}>{r107}</Pressable>;
|
|
return <ICYMICardInCard {...props2} />;
|
|
};
|
|
styles = createICYMIStyles((a0) => ({
|
|
container: {
|
|
marginHorizontal: a0.margin,
|
|
marginBottom: a0.margin,
|
|
marginLeft: a0.margin + a0.inset
|
|
},
|
|
card: {
|
|
marginTop: Module712.space.PX_12
|
|
},
|
|
title: {
|
|
marginBottom: Module712.space.PX_4
|
|
},
|
|
timeAndUserPillContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
marginBottom: Module712.space.PX_8,
|
|
justifyContent: "space-between"
|
|
},
|
|
separator: {
|
|
height: 1,
|
|
width: "100%",
|
|
backgroundColor: Module712.colors.BORDER_SUBTLE,
|
|
marginVertical: Module712.space.PX_12
|
|
},
|
|
eventsChannelIcon: {
|
|
tintColor: Module712.colors.INTERACTIVE_TEXT_DEFAULT
|
|
},
|
|
infoContainer: {
|
|
gap: Module712.space.PX_4
|
|
},
|
|
locationContainer: {
|
|
alignItems: "center",
|
|
flexDirection: "row",
|
|
gap: Module712.space.PX_8
|
|
}
|
|
}));
|
|
export default function ICYMIGuildEventRowWrapper(props) {
|
|
const eventId = props.eventId;
|
|
const stateFromStores = useStateFromStores([GuildScheduledEventStore], () => GuildScheduledEventStore.getGuildScheduledEvent(eventId));
|
|
const stateFromStores2 = useStateFromStores([GuildStore], () => GuildStore.getGuild(stateFromStores?.guild_id));
|
|
const stateFromStores3 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(stateFromStores?.channel_id));
|
|
return stateFromStores == null ? null : stateFromStores2 == null ? null : isGuildEventEnded(stateFromStores) ? null : <ICYMIGuildEventRow event={stateFromStores} channel={stateFromStores3} guild={stateFromStores2} />;
|
|
};
|