637 lines
25 KiB
TypeScript
637 lines
25 KiB
TypeScript
// Metro module 15288 (f15289).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import { useRef, memo, useCallback, useState, useEffect } from "react";
|
|
import { RefreshControl, View, StyleSheet } from "react-native";
|
|
import AccessibilityStore from "../../a11y/AccessibilityStore";
|
|
import ApplicationStore from "../../applications/ApplicationStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import NotificationCenterStore from "../NotificationCenterStore";
|
|
import { AnalyticEvents, AnalyticsLocations, EMPTY_STRING_SNOWFLAKE_ID, MessageFlags, MessageTypes } from "../../../Constants";
|
|
import { NotificationTypes } from "../../push_notifications/PushNotificationConstants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import { Text, TextStyleSheet } from "../../../design/components/Text/native/Text";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { getParser, getNotifCenterV2MessagePreviewParser, getParserWithoutLinks } from "../../markup/CustomMarkup.native";
|
|
import { ForYouMentionPlaceholder } from "./ForYouMentionPlaceholder";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import * as _Module1384 from "../../../_bundle/Module1384";
|
|
import parsePollResultSystemMessageEmbed from "../../polls/parsePollResultSystemMessageEmbed";
|
|
import { formatPollResultNotificationCenterText } from "../../polls/PollsUtils";
|
|
import Module9872 from "../../../_bundle/Module9872";
|
|
import Module9656 from "../../../_bundle/Module9656";
|
|
import Module7676 from "../../../_bundle/Module7676";
|
|
import { useStateFromStores, useStateFromStoresArray } from "../../../_bundle/Module589";
|
|
import { renderMessageContentMarkup } from "../../messages/renderMessageMarkup";
|
|
import { Icon, IconSizes } from "../../../design/void/native";
|
|
import ApplicationIconAndName from "../../user_profile/native/ApplicationIconAndName";
|
|
import { useNotificationCenterItemAcked } from "../useNotificationCenterItemAcked";
|
|
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
|
|
import parseURL from "../../../utils/native/parseURL";
|
|
import handleSupportedURL from "../../links/native/handleSupportedURL";
|
|
import { NotificationCenterLocalItems, NotificationCenterActionTypes, NotificationCenterItems } from "../NotificationCenterItemsTypes";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import Module8011 from "../../../_bundle/Module8011";
|
|
import { LightbulbIcon } from "../../../design/components/Icon/native/redesign/generated/LightbulbIcon";
|
|
import { openGuildHighlightNotificationForPush } from "../../notifications/native/GuildHighlightsNotificationsActionCreators";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import Module15292 from "../../../_bundle/Module15292";
|
|
import { TrashIcon } from "../../../design/components/Icon/native/redesign/generated/TrashIcon";
|
|
import { deleteNotificationCenterItem } from "../NotificationCenterItemsActions";
|
|
import { showSimpleActionSheet } from "../../action_sheet/native/showSimpleActionSheet";
|
|
import { useItemActionButtonPropsV2, ForYouItemActionButtons } from "./ForYouItemActionButtons";
|
|
import getNotificationCenterItemBody from "../getNotificationCenterItemBody";
|
|
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
|
|
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
|
|
import { ForYouItemImage } from "./ForYouItemImage";
|
|
import { getRelativeTimestamp } from "../NotificationCenterUtils";
|
|
import FriendRequestNote from "../../people/native/FriendRequestNote";
|
|
import { useScrollToTop } from "../../../_bundle/Module1481";
|
|
import { NotificationCenterAckedBeforeId, ChannelListLayoutSetting } from "../../user_settings/UserSettings";
|
|
import { ChannelListLayoutTypes } from "../../main_tabs_v2/ChannelListLayoutTypes";
|
|
import { ForYouReadSectionHeader } from "./ForYouReadSectionHeader";
|
|
import { ForYouRecentActivitySectionHeader } from "./ForYouRecentActivitySectionHeader";
|
|
import { ForYouHoistedItemsHeader } from "./ForYouHoistedItemsHeader";
|
|
import ForYouSuggestedFriendsSectionHeader from "./ForYouSuggestedFriendsSectionHeader";
|
|
import ForYouSuggestedFriendRow from "./ForYouSuggestedFriendRow";
|
|
import { ForYouSuggestedFriendShowAllRow } from "./ForYouShowAllRow";
|
|
import { ErrorBoundary } from "../../../_bundle/Module810";
|
|
import { ForYouUnreadClearedState } from "./ForYouUnreadClearedState";
|
|
import { ForYouLoadMore } from "./ForYouLoadMore";
|
|
import { assertNever } from "../../../utils/GlobalUtils";
|
|
import { refreshNotifications } from "../NotificationCenterStoreActions";
|
|
import { FlashList } from "../../../_bundle/noop_6676";
|
|
import { ForYouEmptyState } from "./ForYouEmptyState";
|
|
import { HermesBuiltin } from "../../../_hermes/prelude";
|
|
let viewabilityConfig, useStyles, useStyles2, useStyles3, useStyles4, c10865_28, useStyles5, c10865_31, Callout, ForYouMessagePreviewV2, ApplicationName, Component, ScrollToTopRef, extractKey;
|
|
const ForYouFooter = function ForYouFooter(props) {
|
|
return props.loading ? <ForYouMentionPlaceholder /> : null;
|
|
};
|
|
Callout = function Callout(props) {
|
|
const { item: item3, acked, compactMode: compactMode2 } = props;
|
|
const styles5 = useStyles5();
|
|
return <View style={styles5.calloutContainer} pointerEvents="none">
|
|
<View style={styles5.messagePreviewBarV2} />
|
|
<Text style={[acked ? styles5.calloutTextAcked : styles5.calloutTextNotAcked]} variant="redesign/message-preview/medium" lineClamp={compactMode2 ? 3 : 10}>
|
|
{getParser(useStyles3())(item3.callout)}
|
|
</Text>
|
|
</View>;
|
|
};
|
|
ForYouMessagePreviewV2 = function ForYouMessagePreviewV2(props) {
|
|
let r74, content2;
|
|
const { item, acked, compactMode: compactMode2, roleStyle } = props;
|
|
const styles5 = useStyles5();
|
|
const notifCenterV2MessagePreviewParser = getNotifCenterV2MessagePreviewParser(useStyles4(), c10865_28, roleStyle);
|
|
const r40 = intl.string(t.BOi07B);
|
|
let r44 = item.message?.flags;
|
|
if (r44 == null) {
|
|
r44 = 0;
|
|
}
|
|
const hasFlag = _Module1384.hasFlag(r44, MessageFlags.IS_VOICE_MESSAGE);
|
|
const type = item.message?.type;
|
|
const POLL_RESULT = MessageTypes.POLL_RESULT;
|
|
let r53 = item.message?.attachments;
|
|
if (r53 == null) {
|
|
r53 = [];
|
|
}
|
|
const length = r53.length;
|
|
let r57 = item.message?.stickers;
|
|
if (r57 == null) {
|
|
r57 = [];
|
|
}
|
|
const length2 = r57.length;
|
|
let r60 = item.message?.embeds;
|
|
if (r60 == null) {
|
|
r60 = [];
|
|
}
|
|
const length3 = r60.length;
|
|
const r64 = item.message?.interaction != null;
|
|
if (type === POLL_RESULT) {
|
|
const message = item.message;
|
|
const r119 = message == null;
|
|
let r120 = void 0;
|
|
if (!r119) {
|
|
const embeds = message.embeds;
|
|
r120 = embeds == null ? void 0 : embeds[0];
|
|
}
|
|
const r126 = parsePollResultSystemMessageEmbed(r120);
|
|
const r127 = r126 != null;
|
|
content2 = r40;
|
|
r74 = void 0;
|
|
if (r127) {
|
|
content2 = formatPollResultNotificationCenterText(r126);
|
|
r74 = void 0;
|
|
}
|
|
} else if (length2 > 0) {
|
|
content2 = intl.string(t["7K5Lma"]);
|
|
r74 = c10865_31.STICKER;
|
|
} else if (r64) {
|
|
content2 = intl.string(t["2v7kfl"]);
|
|
r74 = void 0;
|
|
} else if (hasFlag) {
|
|
content2 = intl.string(t["6bhHrc"]);
|
|
r74 = c10865_31.VOICE_MESSAGE;
|
|
} else {
|
|
let r70 = item.message?.flags;
|
|
if (r70 == null) {
|
|
r70 = 0;
|
|
}
|
|
if (_Module1384.hasFlag(r70, MessageFlags.IS_COMPONENTS_V2)) {
|
|
content2 = intl.string(t.Xxm5i3);
|
|
r74 = void 0;
|
|
} else {
|
|
const r73 = length > 0 || length3 > 0;
|
|
content2 = r40;
|
|
r74 = void 0;
|
|
if (r73) {
|
|
content2 = intl.string(t.JAKsM8);
|
|
r74 = c10865_31.ATTACHMENT;
|
|
}
|
|
}
|
|
}
|
|
const content = item.message?.content;
|
|
const r134 = content != null && content !== "";
|
|
if (r134) {
|
|
content2 = content;
|
|
}
|
|
const { guild_id, message_channel_id, message_id } = item;
|
|
useStateFromStores([GuildStore], () => GuildStore.getGuild(guild_id));
|
|
useStateFromStores([ChannelStore], () => ChannelStore.getChannel(message_channel_id));
|
|
useStateFromStoresArray([UserStore], () => {
|
|
const message = item.message;
|
|
const r16 = [UserStore.getUser(message == null ? void 0 : message.author.id)];
|
|
const message2 = item.message;
|
|
const r18 = message2 == null;
|
|
let r19 = void 0;
|
|
if (!r18) {
|
|
const mentions = message2.mentions;
|
|
r19 = mentions == null ? void 0 : mentions.map((mention) => UserStore.getUser(mention));
|
|
}
|
|
if (r19 == null) {
|
|
r19 = [];
|
|
}
|
|
HermesBuiltin.arraySpread(r16, r19, 1);
|
|
return r16;
|
|
});
|
|
const r167 = [<View style={styles5.messagePreviewBarV2} />, ,];
|
|
const style = [acked ? styles5.messagePreviewTextV2Acked : styles5.messagePreviewTextV2NotAcked, r134 ? void 0 : styles5.messagePreviewSystemTextV2];
|
|
const lineClamp = compactMode2 ? 3 : 10;
|
|
const message2 = item.message;
|
|
r167[1] = <Text style={style} variant="redesign/message-preview/medium" lineClamp={lineClamp}>
|
|
{renderMessageContentMarkup(notifCenterV2MessagePreviewParser, {
|
|
content: content2,
|
|
guildId: guild_id,
|
|
channelId: message_channel_id,
|
|
messageId: message_id,
|
|
authorId: message2 == null ? void 0 : message2.author.id
|
|
}, {})}
|
|
{r74 != null && <View style={styles5.messagePreviewIconV2Container}>
|
|
<Icon source={c10865_31.ATTACHMENT === r74 ? Module9872 : c10865_31.STICKER === r74 ? Module9656 : c10865_31.VOICE_MESSAGE === r74 ? Module7676 : null} size={IconSizes.SMALL} style={styles5.messagePreviewIconV2} />
|
|
</View>}
|
|
</Text>;
|
|
return <View style={styles5.messagePreviewContainerV2} pointerEvents="none">{r167}</View>;
|
|
};
|
|
ApplicationName = function ApplicationName(props) {
|
|
const { applicationId, textVariant: textVariant2 } = props;
|
|
const stateFromStores3 = useStateFromStores([ApplicationStore], () => ApplicationStore.getApplication(applicationId));
|
|
return stateFromStores3 == null ? <View /> : <ApplicationIconAndName key={stateFromStores3.id} application={stateFromStores3} textVariant={textVariant2} iconSize={16} />;
|
|
};
|
|
ScrollToTopRef = function ScrollToTopRef({ scrollRef }) {
|
|
useScrollToTop(useRef({
|
|
scrollToTop: () => {
|
|
const current = scrollRef.current;
|
|
return current == null ? void 0 : current.scrollToTop();
|
|
}
|
|
}));
|
|
return null;
|
|
};
|
|
extractKey = function extractKey(a0) {
|
|
return a0.id;
|
|
};
|
|
viewabilityConfig = {
|
|
waitForInteraction: false,
|
|
viewAreaCoveragePercentThreshold: 100,
|
|
minimumViewTime: 1000
|
|
};
|
|
useStyles = createStyles({
|
|
strong: {
|
|
...TextStyleSheet["text-md/medium"],
|
|
color: Module712.colors.MOBILE_TEXT_HEADING_PRIMARY
|
|
}
|
|
});
|
|
useStyles2 = createStyles({
|
|
strong: {
|
|
...TextStyleSheet["text-md/medium"],
|
|
color: Module712.colors.TEXT_MUTED
|
|
}
|
|
});
|
|
useStyles3 = createStyles({
|
|
mention: {
|
|
color: Module712.colors.MENTION_FOREGROUND,
|
|
backgroundColor: Module712.colors.MENTION_BACKGROUND
|
|
}
|
|
});
|
|
useStyles4 = createStyles({
|
|
mention: {
|
|
color: Module712.colors.MENTION_FOREGROUND,
|
|
backgroundColor: "transparent"
|
|
},
|
|
em: {
|
|
fontStyle: "normal"
|
|
}
|
|
});
|
|
c10865_28 = {
|
|
channelMentionText: "redesign/message-preview/medium"
|
|
};
|
|
useStyles5 = createStyles({
|
|
container: {
|
|
flex: 1
|
|
},
|
|
row: {
|
|
marginHorizontal: 4,
|
|
paddingHorizontal: 12,
|
|
paddingVertical: 8,
|
|
marginBottom: 4,
|
|
borderRadius: Module712.radii.lg,
|
|
flexDirection: "row",
|
|
justifyContent: "space-between"
|
|
},
|
|
rowCompact: {
|
|
paddingVertical: 6
|
|
},
|
|
rowActive: {
|
|
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED
|
|
},
|
|
col: {
|
|
flexDirection: "column",
|
|
flex: 1
|
|
},
|
|
unreadIndicatorV2: {
|
|
top: 28,
|
|
backgroundColor: Module712.colors.BACKGROUND_BRAND,
|
|
height: 8,
|
|
width: 8,
|
|
borderRadius: Module712.radii.xs,
|
|
position: "absolute",
|
|
left: 4
|
|
},
|
|
unreadIndicatorCompactV2: {
|
|
top: 18
|
|
},
|
|
rowText: {
|
|
flex: 1
|
|
},
|
|
rowTextV2: {
|
|
flexDirection: "row",
|
|
justifyContent: "space-between"
|
|
},
|
|
rowBody: {
|
|
lineHeight: 20
|
|
},
|
|
rowBodyV2: {
|
|
marginRight: 30
|
|
},
|
|
rowBodyAcked: {
|
|
color: Module712.colors.TEXT_MUTED
|
|
},
|
|
rowTime: {
|
|
lineHeight: 20
|
|
},
|
|
rowTimeV2: {
|
|
marginLeft: -24
|
|
},
|
|
itemV2: {
|
|
alignItems: "flex-start",
|
|
marginRight: 4,
|
|
marginLeft: 8
|
|
},
|
|
calloutContainer: {
|
|
marginTop: 4,
|
|
flexDirection: "row",
|
|
marginRight: 16
|
|
},
|
|
calloutTextAcked: {
|
|
color: Module712.colors.TEXT_MUTED
|
|
},
|
|
calloutTextNotAcked: {
|
|
color: Module712.colors.TEXT_DEFAULT
|
|
},
|
|
messagePreviewContainerV2: {
|
|
marginTop: 4,
|
|
flexDirection: "row",
|
|
marginRight: 16
|
|
},
|
|
messagePreviewBarV2: {
|
|
marginRight: 8,
|
|
borderLeftColor: Module712.colors.BORDER_SUBTLE,
|
|
borderLeftWidth: 3,
|
|
borderRadius: 2,
|
|
height: "auto"
|
|
},
|
|
messagePreviewIconV2Container: {
|
|
paddingTop: 4
|
|
},
|
|
messagePreviewIconV2: {
|
|
marginLeft: 4,
|
|
tintColor: Module712.colors.TEXT_SUBTLE
|
|
},
|
|
messagePreviewTextV2Acked: {
|
|
color: Module712.colors.TEXT_MUTED
|
|
},
|
|
messagePreviewTextV2NotAcked: {
|
|
color: Module712.colors.TEXT_DEFAULT
|
|
},
|
|
messagePreviewSystemTextV2: {
|
|
fontStyle: "italic",
|
|
fontWeight: "normal"
|
|
},
|
|
refreshSpinner: {
|
|
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
|
|
},
|
|
forYouDivider: {
|
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
borderTopColor: Module712.colors.BORDER_SUBTLE,
|
|
marginTop: Module712.space.PX_12,
|
|
marginBottom: Module712.space.PX_8
|
|
},
|
|
friendRequestNoteContainer: {
|
|
marginTop: 4,
|
|
backgroundColor: Module712.colors.BACKGROUND_MOD_SUBTLE
|
|
}
|
|
});
|
|
c10865_31 = {
|
|
STICKER: "sticker",
|
|
VOICE_MESSAGE: "voice_message",
|
|
ATTACHMENT: "attachment"
|
|
};
|
|
Component = memo(function(a0) {
|
|
let textVariant;
|
|
const { item: item2, ackedBeforeId, rowIndex } = a0;
|
|
let isSoftAcked2 = a0.isSoftAcked;
|
|
const { onSoftAckItem, forceHoistItem: forceHoistItem2, isForceHoisted: isForceHoisted2, compactMode: compactMode2, roleStyle } = a0;
|
|
textVariant = void 0;
|
|
const styles5 = useStyles5();
|
|
let r45 = useNotificationCenterItemAcked(item2, ackedBeforeId);
|
|
const notificationCenterItemAcked = r45;
|
|
if (!isSoftAcked2) {
|
|
isSoftAcked2 = notificationCenterItemAcked;
|
|
}
|
|
const navigation = useNavigation();
|
|
const callback = useCallback(() => {
|
|
if (item2.deeplink != null) {
|
|
handleSupportedURL({
|
|
payload: parseURL(item2.deeplink).payload,
|
|
safe: true,
|
|
navigationReplace: false
|
|
});
|
|
}
|
|
}, [item2]);
|
|
const callback3 = useCallback(() => {
|
|
if (!notificationCenterItemAcked) {
|
|
onSoftAckItem(item2);
|
|
}
|
|
if (item2.type === NotificationCenterLocalItems.FRIEND_REQUESTS_GROUPED && navigation != null) {
|
|
navigation.navigate("friends", {
|
|
screen: "requests"
|
|
});
|
|
}
|
|
callback();
|
|
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_CENTER_ACTION, {
|
|
action_type: NotificationCenterActionTypes.CLICKED,
|
|
notification_center_id: item2.id,
|
|
item_type: item2.type,
|
|
acked: notificationCenterItemAcked,
|
|
item_index: rowIndex,
|
|
deeplink: item2.deeplink
|
|
});
|
|
}, [notificationCenterItemAcked, item2, callback, rowIndex, onSoftAckItem, navigation]);
|
|
const callback4 = useCallback(() => {
|
|
const options = [];
|
|
if (item2.type === NotificationCenterItems.TRENDING_CONTENT) {
|
|
options.push({
|
|
label: intl.string(t["gSMz/x"]),
|
|
icon: Module8011,
|
|
IconComponent: LightbulbIcon,
|
|
onPress: () => {
|
|
try {
|
|
let deeplink = item2.deeplink;
|
|
if (deeplink == null) {
|
|
deeplink = "";
|
|
}
|
|
const r17 = deeplink.match(/channels\/(\d*)\/(\d*)\/(\d*)\?summaryId=(\d*)/);
|
|
if (r17 == null) {
|
|
throw new Error(`Invalid deeplink: ${item2.deeplink}`);
|
|
}
|
|
const r23 = _slicedToArray(r17, 5);
|
|
r23[0];
|
|
openGuildHighlightNotificationForPush(r23[1], {
|
|
id: r23[3],
|
|
channel_id: r23[2]
|
|
}, NotificationTypes.TRENDING_CONTENT_PUSH, AnalyticsLocations.NOTIFICATION_CENTER, {
|
|
summary_id: r23[4]
|
|
});
|
|
} catch ($e) {
|
|
ToastActionCreators.open({
|
|
key: "USER_SURVEY_ERROR",
|
|
content: intl.string(t.HO9Lf2)
|
|
});
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
options.push({
|
|
label: intl.string(t["08rqg5"]),
|
|
icon: Module8011,
|
|
IconComponent: LightbulbIcon,
|
|
onPress: () => {
|
|
try {
|
|
ActionSheetActionCreators.openLazy(import("../../notifications/native/NotificationSurveyActionSheet"), "NotificationSurvey", {
|
|
notificationType: item2.type,
|
|
location: AnalyticsLocations.NOTIFICATION_CENTER
|
|
});
|
|
} catch ($e) {
|
|
ToastActionCreators.open({
|
|
key: "USER_SURVEY_ERROR",
|
|
content: intl.string(t.HO9Lf2)
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
if (item2.local_id == null) {
|
|
const r65 = {
|
|
label: intl.string(t.D8z9ju),
|
|
icon: Module15292,
|
|
IconComponent: TrashIcon,
|
|
onPress: null
|
|
};
|
|
let c27987_0 = async () => {
|
|
let c30862_3 = 0;
|
|
L10: {
|
|
try {
|
|
c30862_3 = 1;
|
|
await deleteNotificationCenterItem(item2);
|
|
c30862_3 = 0;
|
|
} catch ($e) {
|
|
let r7 = $e;
|
|
if (c30862_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c30862_3 = 0;
|
|
ToastActionCreators.open({
|
|
key: "REMOVE_NOTIFICATION_ERROR",
|
|
content: intl.string(t.WDxhvB)
|
|
});
|
|
break L10;
|
|
} catch ($e) {
|
|
r7 = $e;
|
|
if (c30862_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
};
|
|
r65.onPress = function() {
|
|
return c27987_0.apply(this, arguments);
|
|
};
|
|
options.unshift(r65);
|
|
}
|
|
showSimpleActionSheet({
|
|
key: "ForYouItemLongPress",
|
|
options,
|
|
hasIcons: true
|
|
});
|
|
}, [item2]);
|
|
const r61 = _slicedToArray(useState(void 0), 2);
|
|
let r30 = r61[0];
|
|
const itemActionButtonPropsV2 = useItemActionButtonPropsV2(item2, callback, navigation, forceHoistItem2, isForceHoisted2, onSoftAckItem, r61[1], compactMode2);
|
|
const { actionButtons, actionsNode, accessibilityActions, onAccessibilityAction } = itemActionButtonPropsV2;
|
|
const parserWithoutLinks2 = getParserWithoutLinks(useStyles2());
|
|
const parserWithoutLinks = getParserWithoutLinks(useStyles());
|
|
const r2 = item2.type === NotificationCenterItems.FRIEND_REQUEST_ACCEPTED || item2.type === NotificationCenterItems.GAME_FRIEND_REQUEST_ACCEPTED;
|
|
if (notificationCenterItemAcked) {
|
|
r45 = !r2;
|
|
}
|
|
const r91 = r45 ? null : <ForYouItemActionButtons aria-hidden accessibilityLabel="" item={item2} rowIndex={rowIndex} onSoftAckItem={onSoftAckItem} actionButtons={actionButtons} actionsNode={actionsNode} compactMode={compactMode2} />;
|
|
textVariant = isSoftAcked2 ? "text-md/medium" : "text-md/semibold";
|
|
if (r30 == null) {
|
|
r30 = getNotificationCenterItemBody({
|
|
item: item2,
|
|
renderApplication: (a0) => <ApplicationName applicationId={a0} textVariant={textVariant} />
|
|
});
|
|
}
|
|
const r29 = SnowflakeUtils.extractTimestamp(item2.id);
|
|
const style = [styles5.row, !!compactMode2 && styles5.rowCompact];
|
|
const r127 = [item2.enableBadge ? isSoftAcked2 ? null : <View style={[styles5.unreadIndicatorV2, !!compactMode2 && styles5.unreadIndicatorCompactV2]} /> : null, <View style={styles5.itemV2}>
|
|
<ForYouItemImage item={item2} compactMode={compactMode2} />
|
|
</View>, ,];
|
|
const style2 = [styles5.rowBody, styles5.rowBodyV2, !!isSoftAcked2 && styles5.rowBodyAcked];
|
|
let r154 = r30;
|
|
if (typeof r154 === "string") {
|
|
r154 = isSoftAcked2 ? parserWithoutLinks2(r30) : parserWithoutLinks(r30);
|
|
}
|
|
const r178 = [<View style={[styles5.rowText, styles5.rowTextV2]}>
|
|
<Text variant={textVariant} style={style2} color="text-default">{r154}</Text>
|
|
<Text variant="text-xs/medium" style={[styles5.rowTime, styles5.rowTimeV2, !!isSoftAcked2 && styles5.rowBodyAcked]} color="text-default" accessibilityLabel={getRelativeTimestamp(r29, false)}>
|
|
{getRelativeTimestamp(r29)}
|
|
</Text>
|
|
</View>, , , , ,];
|
|
let r184 = item2.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS;
|
|
if (r184) {
|
|
let userId = item2.other_user?.id;
|
|
if (userId == null) {
|
|
userId = EMPTY_STRING_SNOWFLAKE_ID;
|
|
}
|
|
r184 = <FriendRequestNote styles={styles5.friendRequestNoteContainer} backgroundColor={styles5.friendRequestNoteContainer.backgroundColor} userId={userId} analyticsLocation="Notifications Tab" />;
|
|
}
|
|
r178[1] = r184;
|
|
r178[2] = item2.message?.content != null ? <ForYouMessagePreviewV2 item={item2} acked={isSoftAcked2} compactMode={compactMode2} roleStyle={roleStyle} /> : null;
|
|
r178[3] = item2.callout != null ? <Callout item={item2} acked={isSoftAcked2} compactMode={compactMode2} /> : null;
|
|
r178[4] = <View>{r91}</View>;
|
|
r127[2] = <View style={{
|
|
flex: 1,
|
|
flexDirection: "row"
|
|
}}>
|
|
<View style={styles5.col}>{r178}</View>
|
|
</View>;
|
|
return <PressableHighlight accessibilityRole="button" accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} style={style} onPress={callback3} onAccessibilityTap={callback3} onLongPress={callback4} underlayColor={styles5.rowActive.backgroundColor}>{r127}</PressableHighlight>;
|
|
});
|
|
const r223 = memo(function({ items, onScroll, loadMore, loadingMore, nestedInLaunchPad, shouldScrollToTop, isSoftAcked, onSoftAckItem: onSoftAckItem2, forceHoistItem, isForceHoisted, suggestedFriendAdded, onAddSuggestionAnimationFinish, panelVariant: panelVariant2 = false }) {
|
|
let stateFromStores2, compactMode, callback2, ref, setState;
|
|
const panelVariant = panelVariant2;
|
|
stateFromStores2 = void 0;
|
|
compactMode = void 0;
|
|
callback2 = void 0;
|
|
ref = void 0;
|
|
setState = void 0;
|
|
const styles = useStyles5();
|
|
const setting = NotificationCenterAckedBeforeId.useSetting();
|
|
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.roleStyle);
|
|
stateFromStores2 = useStateFromStores([NotificationCenterStore], () => NotificationCenterStore.isRefreshing());
|
|
compactMode = ChannelListLayoutSetting.useSetting() === ChannelListLayoutTypes.COMPACT;
|
|
callback2 = useCallback(() => {
|
|
loadMore(true);
|
|
}, [loadMore]);
|
|
const callback3 = useCallback(({ item: item3, index }) => {
|
|
switch (item3.kind) {
|
|
case "read-section-header":
|
|
return <ForYouReadSectionHeader />;
|
|
case "recent-activity-section-header":
|
|
return <ForYouRecentActivitySectionHeader />;
|
|
case "hoisted-items-header":
|
|
return <ForYouHoistedItemsHeader />;
|
|
case "suggested-friends-header":
|
|
return <ForYouSuggestedFriendsSectionHeader showDivider={item3.showDivider} />;
|
|
case "suggested-friends-row":
|
|
return <ForYouSuggestedFriendRow suggestedFriend={item3.suggestedFriend} onAddSuggestion={suggestedFriendAdded} onAddSuggestionAnimationFinish={onAddSuggestionAnimationFinish} panelVariant={panelVariant} />;
|
|
case "suggested-friends-show-all-row":
|
|
return <ForYouSuggestedFriendShowAllRow suggestedFriends={item3.suggestedFriends} panelVariant={panelVariant} />;
|
|
case "for-you-divider":
|
|
return <View style={styles.forYouDivider} />;
|
|
case "notification-center-item":
|
|
return <ErrorBoundary>
|
|
<Component key={`${item3.id}-${stateFromStores}`} item={item3} ackedBeforeId={setting} isSoftAcked={isSoftAcked(item3.id)} onSoftAckItem={onSoftAckItem2} forceHoistItem={forceHoistItem} isForceHoisted={isForceHoisted} rowIndex={index} compactMode={compactMode} roleStyle={stateFromStores} />
|
|
</ErrorBoundary>;
|
|
case "mentions-placeholder":
|
|
return <ForYouMentionPlaceholder />;
|
|
case "unread-cleared-placeholder":
|
|
return <ForYouUnreadClearedState />;
|
|
case "load-more":
|
|
return <ForYouLoadMore onPressLoad={callback2} />;
|
|
default:
|
|
assertNever(item3);
|
|
return void 0;
|
|
}
|
|
}, [styles.forYouDivider, suggestedFriendAdded, onAddSuggestionAnimationFinish, stateFromStores, setting, isSoftAcked, onSoftAckItem2, forceHoistItem, isForceHoisted, compactMode, callback2, panelVariant]);
|
|
ref = useRef(null);
|
|
useEffect(() => {
|
|
if (shouldScrollToTop) {
|
|
const current = ref.current;
|
|
if (current != null) {
|
|
current.scrollToOffset({
|
|
animated: false,
|
|
offset: 0
|
|
});
|
|
}
|
|
}
|
|
}, [shouldScrollToTop]);
|
|
const callback4 = useCallback(() => {
|
|
if (!stateFromStores2) {
|
|
refreshNotifications();
|
|
}
|
|
}, [stateFromStores2]);
|
|
let height;
|
|
[height, setState] = useState(0);
|
|
return <View style={styles.container} onLayout={(event) => setState(event.nativeEvent.layout.height)}>
|
|
{nestedInLaunchPad ? !nestedInLaunchPad : <ScrollToTopRef scrollRef={ref} />}
|
|
<FlashList ref={ref} data={items} ListEmptyComponent={<ForYouEmptyState height={height} />} onScroll={onScroll} refreshControl={<RefreshControl onRefresh={callback4} refreshing={stateFromStores2} tintColor={styles.refreshSpinner.color} />} keyExtractor={extractKey} renderItem={callback3} extraData={setting} onEndReached={loadMore} onEndReachedThreshold={0.8} ListFooterComponent={<ForYouFooter loading={loadingMore} />} viewabilityConfig={viewabilityConfig} />
|
|
</View>;
|
|
});
|
|
export { r223 as ForYouItems };
|