96 lines
4.8 KiB
TypeScript
96 lines
4.8 KiB
TypeScript
// Metro module 10378 (f10379).
|
|
import { memo, useMemo, useCallback } from "react";
|
|
import { View } from "react-native";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import { IN_APP_NOTIFICATION_MAX_HEIGHT, NOTIFICATION_PREVIEW_LINE_CLAMP, RIGHT_ACCESSORY_LEFT_MARGIN } from "./InAppNotificationConstants";
|
|
import { AnalyticEvents } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import { Avatar, AvatarSizes, CutoutDirection } from "../../../design/void/native";
|
|
import { ClockIcon } from "../../../design/components/Icon/native/redesign/generated/ClockIcon";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useHasPreviewableMedia, getMessagePreviewTextVariant } from "./InAppNotificationUtils";
|
|
import { MediaPreviewRightAccessory } from "./MediaPreviewRightAccessory";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { ChannelTypes } from "../../../_bundle/Module692";
|
|
import MessageNotificationHeader from "./MessageNotificationHeader";
|
|
import MessagePreviewText from "./MessagePreviewText";
|
|
import { ChannelRowPreview } from "../../main_tabs_v2/native/shared_components/ChannelRowPreview";
|
|
import { ChannelListLayoutTypes } from "../../main_tabs_v2/ChannelListLayoutTypes";
|
|
import Module38 from "../../../_bundle/Module38";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import { showForLaterModal } from "../../saved_messages/native/showForLaterModal";
|
|
import { SavedMessageSortTypes } from "../../saved_messages/SavedMessagesTypes";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { NotificationPressable } from "./Notification";
|
|
let useStyles, cutout, Component, NotificationBody;
|
|
const NotificationAvatar = function NotificationAvatar(props) {
|
|
const { user, guildId } = props;
|
|
const styles = useStyles();
|
|
return <View style={styles.avatarContainer}>
|
|
<Avatar user={user} guildId={guildId} size={AvatarSizes.NORMAL} cutout={cutout} />
|
|
<View style={styles.cutoutIconContainer}>
|
|
<ClockIcon size="xs" color={Module712.colors.ICON_SUBTLE} />
|
|
</View>
|
|
</View>;
|
|
};
|
|
NotificationBody = function NotificationBody(props) {
|
|
const { channel, message } = props;
|
|
const stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(channel.guild_id));
|
|
const stateFromStores2 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channel.parent_id));
|
|
const hasPreviewableMedia = useHasPreviewableMedia(message);
|
|
const r2 = channel.type === ChannelTypes.DM;
|
|
const lineClamp = r2 ? NOTIFICATION_PREVIEW_LINE_CLAMP : 1;
|
|
const messagePreviewTextVariant = getMessagePreviewTextVariant();
|
|
return <>
|
|
{r2 ? null : <MessageNotificationHeader channel={channel} parentChannel={stateFromStores2} guild={stateFromStores} author={null} />}
|
|
{!hasPreviewableMedia && message.poll == null ? <ChannelRowPreview channel={channel} message={message} color="text-default" layout={ChannelListLayoutTypes.COZY} variant={messagePreviewTextVariant} muted={false} lineClamp={lineClamp} /> : <MessagePreviewText message={message} lineClamp={lineClamp} showMessageAuthor maxHeight={IN_APP_NOTIFICATION_MAX_HEIGHT} />}
|
|
</>;
|
|
};
|
|
useStyles = createStyles({
|
|
cutoutIconContainer: {
|
|
position: "absolute",
|
|
right: 0,
|
|
bottom: 0
|
|
},
|
|
avatarContainer: {
|
|
position: "relative"
|
|
},
|
|
rightAccessoryContainer: {
|
|
marginLeft: RIGHT_ACCESSORY_LEFT_MARGIN
|
|
}
|
|
});
|
|
cutout = {
|
|
direction: CutoutDirection.BOTTOM_RIGHT,
|
|
radius: 10,
|
|
inset: -2
|
|
};
|
|
Component = memo(function({ message }) {
|
|
const styles = useStyles();
|
|
return useHasPreviewableMedia(message) ? <View style={styles.rightAccessoryContainer}>
|
|
<MediaPreviewRightAccessory message={message} />
|
|
</View> : null;
|
|
});
|
|
const r55 = memo(function ReminderNotification(props) {
|
|
const notification = props.notification;
|
|
const { savedMessage, author, channel: channel2 } = notification;
|
|
const message = savedMessage.message;
|
|
Module38(message != null, "Message in a notification should not be null.");
|
|
return <NotificationPressable icon={<NotificationAvatar user={author} guildId={channel2.guild_id} />} header={useMemo(() => ({
|
|
type: "simple",
|
|
text: intl.string(t.Whs8tE)
|
|
}), [])} onPress={useCallback(() => {
|
|
ModalActionCreators.popAll();
|
|
showForLaterModal(SavedMessageSortTypes.REMINDER);
|
|
AnalyticsUtils.track(AnalyticEvents.FOR_LATER_REMINDER_NOTIFICATION_CLICKED, {
|
|
message_id: notification.savedMessage.saveData.messageId,
|
|
message_author_id: notification.author.id,
|
|
notification_type: "IN_APP"
|
|
});
|
|
}, [notification])} notification={notification} rightAccessory={<Component message={message} />}>
|
|
<NotificationBody channel={channel2} message={message} />
|
|
</NotificationPressable>;
|
|
});
|
|
export default r55;
|