This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,348 @@
// Metro module 15281 (f15282).
import { useMemo, useState, useCallback, useRef, useLayoutEffect, useEffect } from "react";
import { View } from "react-native";
import GuildReadStateStore from "../../../stores/GuildReadStateStore";
import ReadStateStore from "../../../stores/ReadStateStore";
import UserStore from "../../../stores/UserStore";
import NotificationCenterItemsStore from "../NotificationCenterItemsStore";
import NotificationCenterStore from "../NotificationCenterStore";
import { AnalyticEvents } from "../../../Constants";
import { YouBarNavigatorScreens, RootNavigatorScreen } from "../../main_tabs_v2/native/MainTabsConstants";
import { ReadStateTypes } from "../../read_states/ReadStateConstants";
import { NotificationCenterLocalItems } from "../NotificationCenterItemsTypes";
import { useIsFocused } from "../../../_bundle/Module1481";
import { useCurrentNavigationRouteName } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
import { NotificationCenterAckedBeforeId, ChannelListLayoutSetting } from "../../user_settings/UserSettings";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import { ChannelListLayoutTypes } from "../../main_tabs_v2/ChannelListLayoutTypes";
import { useNotificationCenterItemsLoader } from "../useNotificationCenterItemsLoader";
import { useStateFromStores } from "../../../_bundle/Module589";
import { useGetOrFetchNotificationCenterItemsApplications } from "../useGetOrFetchNotificationCenterItemApplications";
import useSuggestedFriends from "../../main_tabs_v2/native/friends/components/useSuggestedFriends";
import { useShouldAgeVerifyForAgeGate, shouldShowAgeGateForChannelId } from "../../age_gate/AgeGateUtils";
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
import * as _NotificationCenterUtils from "../NotificationCenterUtils";
import { isMentionItem } from "../NotificationCenterUtils";
import parseURL from "../../../utils/native/parseURL";
import { LinkingTypes } from "../../../ConstantsIOS";
import Module12 from "../../../_bundle/Module12";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { markNotificationCenterLocalItemsAcked, bulkMarkNotificationCenterItemsAcked, setNotificationCenterTabFocused } from "../NotificationCenterItemsActions";
import { clearNotificationGuildMentions } from "../NotificationCenterStoreActions";
import useTrackImpression from "../../app_analytics/useTrackImpression";
import { ImpressionTypes, ImpressionNames } from "../../../_bundle/Module503";
import { ForYouMentionPlaceholder } from "./ForYouMentionPlaceholder";
import { ForYouItems } from "./ForYouItems";
let $mk116907 = function() {
return (a0, a1) => -1 * SnowflakeUtils.compare(a0.id, a1.id);
};
let c10858_15 = new Set([RootNavigatorScreen.YOU, RootNavigatorScreen.SETTINGS, YouBarNavigatorScreens.GUILDS, YouBarNavigatorScreens.ICYMI, YouBarNavigatorScreens.NOTIFICATIONS]);
export const NotificationCenterForYou = ({ panelVariant = false, ...rest }) => {
let height, c21841_5, initialized, hasMore, items, setReadNotifItemToAcked, errored, stateFromStores, stateFromStores2, stateFromStores3, stateFromStores4, state, setState, setState2, state2, state3, setState3, ref, ref2, callback, setAdded, friendSuggestions, shouldAgeVerifyForAgeGate, memo2;
height = void 0;
c21841_5 = void 0;
initialized = void 0;
hasMore = void 0;
items = void 0;
setReadNotifItemToAcked = void 0;
errored = void 0;
stateFromStores = void 0;
stateFromStores2 = void 0;
stateFromStores3 = void 0;
stateFromStores4 = void 0;
state = void 0;
setState = void 0;
setState2 = void 0;
state2 = void 0;
state3 = void 0;
setState3 = void 0;
ref = void 0;
ref2 = void 0;
callback = void 0;
setAdded = void 0;
friendSuggestions = void 0;
shouldAgeVerifyForAgeGate = void 0;
memo2 = void 0;
const isFocused = useIsFocused();
const currentNavigationRouteName = useCurrentNavigationRouteName();
const setting = NotificationCenterAckedBeforeId.useSetting();
const memo = useMemo(() => {
const r6 = c10858_15.has(currentNavigationRouteName);
return (isFocused ? !isFocused : currentNavigationRouteName !== YouBarNavigatorScreens.NOTIFICATIONS) && r6;
}, [currentNavigationRouteName, isFocused]);
height = useWindowDimensions_native().height;
const r70 = ChannelListLayoutSetting.useSetting() === ChannelListLayoutTypes.COMPACT;
c21841_5 = r70;
const notificationCenterItemsLoader = useNotificationCenterItemsLoader({
isFocused,
navigatedAway: memo,
withMentions: true,
initialPageSize: useMemo(() => Math.min(50, Math.max(8, Math.ceil(height / (c21841_5 ? 48 : 68)))), [r70, height])
});
initialized = notificationCenterItemsLoader.initialized;
hasMore = notificationCenterItemsLoader.hasMore;
items = notificationCenterItemsLoader.items;
const { loadMore, loadingMore } = notificationCenterItemsLoader;
setReadNotifItemToAcked = notificationCenterItemsLoader.setReadNotifItemToAcked;
errored = notificationCenterItemsLoader.errored;
stateFromStores = useStateFromStores([NotificationCenterStore], () => NotificationCenterStore.hasNewMentions());
stateFromStores2 = useStateFromStores([NotificationCenterItemsStore], () => NotificationCenterItemsStore.localItems, []);
useGetOrFetchNotificationCenterItemsApplications(stateFromStores2);
stateFromStores3 = useStateFromStores([UserStore, ReadStateStore], () => {
const currentUser = UserStore.getCurrentUser();
return currentUser != null ? ReadStateStore.ackMessageId(currentUser.id, ReadStateTypes.NOTIFICATION_CENTER) : null;
});
stateFromStores4 = useStateFromStores([GuildReadStateStore], () => GuildReadStateStore.getTotalNotificationsMentionCount(true));
[state, setState] = useState(stateFromStores3);
let shouldScrollToTop;
[shouldScrollToTop, setState2] = useState(false);
[state2, ,] = useState(Date.now());
[state3, setState3] = useState(new Set());
const callback2 = useCallback((a0) => state3.has(a0), [state3]);
const callback3 = useCallback((a0) => {
if (!a0.forceUnacked && !state3.has(a0.id)) {
const set = new Set(state3);
set.add(a0.id);
setState3(set);
}
}, [state3]);
ref = useRef(new Set());
ref2 = useRef(new Set());
const callback4 = useCallback((a0) => {
ref2.current.add(a0.id);
}, []);
callback = useCallback((a0) => ref2.current.has(a0.id), []);
const suggestedFriends = useSuggestedFriends();
setAdded = suggestedFriends.setAdded;
friendSuggestions = suggestedFriends.friendSuggestions;
const callback5 = useCallback((c27979_0) => {
setAdded((prevAdded) => [...prevAdded, c27979_0]);
}, [setAdded]);
const callback6 = useCallback((c27980_0) => {
setAdded((prevAdded) => prevAdded.filter((item) => item.user.id !== c27980_0.user.id));
}, [setAdded]);
shouldAgeVerifyForAgeGate = useShouldAgeVerifyForAgeGate();
memo2 = useMemo(() => {
const r22 = items.length > 0 ? items[items.length - 1].id : void 0;
let c27981_1, c27981_2, c27981_3, c27981_4;
const id = r22;
const r29 = [...items, ...hasMore && id != null ? stateFromStores2.filter((item) => item.forceUnacked || SnowflakeUtils.compare(item.id, id) > 0) : stateFromStores2];
const r14 = shouldAgeVerifyForAgeGate ? r29.filter((item) => item.kind !== "notification-center-item" || !shouldShowAgeGateForChannelId(item.message_channel_id)) : r29;
const r38 = [];
c27981_1 = r38;
const r39 = [];
c27981_2 = r39;
const r40 = [];
c27981_3 = r40;
r14.forEach((item) => {
let r3;
if (item.kind === "notification-center-item") {
L20: {
if (item.local_id != null) {
const acked = item.acked;
r3 = acked ? !acked : !NotificationCenterStore.isLocalItemAcked(item);
} else {
if (isMentionItem(item) && !item.acked) {
if (item.message_channel_id != null && !ref.current.has(item.id)) {
if (SnowflakeUtils.compare(item.message_id, ReadStateStore.ackMessageId(item.message_channel_id)) <= 0) {
setReadNotifItemToAcked(item);
r3 = false;
break L20;
}
}
if (state != null) {
r3 = SnowflakeUtils.compare(item.id, state) > 0;
break L20;
}
}
const isRemoteAcked = _NotificationCenterUtils.isRemoteAcked(item, setting);
r3 = item.type === "go_live_push" && item.deeplink != null ? parseURL(item.deeplink).payload.type === LinkingTypes.VOICE_CHANNEL && !isRemoteAcked : !isRemoteAcked;
}
}
if (!r3) {
setReadNotifItemToAcked(item);
}
L31: {
if (ref2.current.has(item.id)) {
c27981_1.push(item);
item.acked = false;
} else {
L26: {
if (item.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS) {
if (!r3 && !item.forceUnacked) {
break L26;
}
c27981_1.push(item);
break L31;
}
}
if (r3) {
c27981_2.push(item);
} else {
c27981_3.push(item);
}
}
}
ref.current.add(item.id);
}
});
r38.sort($mk116907());
r39.sort($mk116907());
r40.sort($mk116907());
const [r17, r61] = Module12.partition(r38, (a0) => a0.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS && a0.acked);
const length = r17.length;
let r64 = r38;
if (length > 3) {
r61.push({
kind: "notification-center-item",
type: NotificationCenterLocalItems.FRIEND_REQUESTS_GROUPED,
id: r17[0].id,
local_id: "friend_requests_grouped",
acked: false,
other_user: r17[0].other_user,
other_users: r17.map((item) => item.other_user),
forceUnacked: true
});
c27981_1 = r61;
r64 = r61;
}
r64.forEach((item) => {
const enableBadge = !callback(item);
item.enableBadge = enableBadge;
return enableBadge;
});
const r83 = [];
c27981_4 = r83;
if (friendSuggestions.length > 0) {
r83.push({
kind: "suggested-friends-header",
id: "suggested-friends-header",
showDivider: r64.length > 0
});
friendSuggestions.slice(0, Math.min(friendSuggestions.length, friendSuggestions.length > 3 ? 2 : friendSuggestions.length)).forEach((item) => {
c27981_4.push({
kind: "suggested-friends-row",
id: item.user.id,
suggestedFriend: item
});
});
if (friendSuggestions.length > 3) {
r83.push({
kind: "suggested-friends-show-all-row",
id: "suggested-friends-show-all-row",
suggestedFriends: friendSuggestions
});
}
}
const r107 = [...r39, ...r40];
let r116 = 0;
if (initialized) {
r116 = 0;
if (stateFromStores) {
const r126 = Math.min(Math.max(stateFromStores4, 1), 6);
const r127 = 0 < r126;
let r129 = 0;
r116 = r126;
if (r127) {
do {
r107.unshift({
kind: "mentions-placeholder",
id: `mp-${r129}`
});
r129 = r129 + 1;
r116 = r126;
} while (r129 < r126);
}
}
}
if (errored) {
r107.push({
kind: "load-more",
id: "load-more"
});
}
if (r64.length > 0) {
r64.unshift({
kind: "hoisted-items-header",
id: "hoisted-items-header"
});
}
const r144 = {
kind: "recent-activity-section-header",
id: "rash"
};
const r145 = [];
if (r64.length > 0) {
const r194 = r107.splice(0, 3);
r145.push.apply(r145, [...r64, ...r83]);
if (r194.length > 0 || r107.length > 0) {
r145.push(r144);
}
r145.push.apply(r145, [...r194, ...r107]);
} else {
const r159 = r107.splice(0, r39.length > 0 ? r107.length > 0 ? r107[0].kind === "mentions-placeholder" ? r116 + r39.length - 1 : 3 : 3 : 3);
const r161 = r83.length === 0 && r107.length > 0;
let r163 = false;
if (r161) {
r145.push(r144);
r163 = true;
}
r145.push.apply(r145, [...r159, ...r83]);
if (r163 ? !r163 : r107.length > 0) {
r145.push(r144);
}
r145.push.apply(r145, [...r107]);
}
return r145;
}, [items, hasMore, stateFromStores2, friendSuggestions, initialized, stateFromStores, errored, setting, state, setReadNotifItemToAcked, callback, stateFromStores4, shouldAgeVerifyForAgeGate]);
useLayoutEffect(() => {
if (initialized) {
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_CENTER_LOADED, {
version: "v2",
load_start_timestamp: state2,
tti_millis: Date.now() - state2
});
}
}, [initialized, state2]);
useEffect(() => {
if (memo) {
const r7 = memo2.filter((item) => item.kind === "notification-center-item");
ref2.current.clear();
r7.forEach((item) => {
if (item.type !== NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS) {
item.enableBadge = false;
}
});
if (stateFromStores3 !== state) {
setState(stateFromStores3);
markNotificationCenterLocalItemsAcked(r7.filter((item) => item.local_id != null && !NotificationCenterStore.isLocalItemAcked(item)).map((item) => item.local_id));
bulkMarkNotificationCenterItemsAcked(r7.filter((item) => !_NotificationCenterUtils.isRemoteAcked(item, setting)));
clearNotificationGuildMentions();
}
}
}, [memo, stateFromStores3, state, memo2, setting, setState, callback]);
useEffect(() => {
if (isFocused) {
setState2(false);
}
setNotificationCenterTabFocused(isFocused);
return () => setNotificationCenterTabFocused(false);
}, [isFocused, setState2]);
useEffect(() => {
if (memo) {
setState2(true);
}
}, [memo, setState2]);
useTrackImpression({
type: ImpressionTypes.VIEW,
name: ImpressionNames.NOTIFICATION_CENTER_LANDING,
properties: {
empty: memo2.length === 0
}
}, {
disableTrack: !initialized
}, [initialized]);
return initialized ? <ForYouItems items={memo2} loadingMore={loadingMore} loadMore={loadMore} nestedInLaunchPad={rest.nestedInLaunchPad} shouldScrollToTop={shouldScrollToTop} isSoftAcked={callback2} onSoftAckItem={callback3} forceHoistItem={callback4} isForceHoisted={callback} suggestedFriendAdded={callback5} onAddSuggestionAnimationFinish={callback6} panelVariant={panelVariant} /> : <View>
{Array.from(Array(10)).map((item, index) => <ForYouMentionPlaceholder key={index} />)}
</View>;
};