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,6 @@
// Metro module 15296 (f15297).
export const PROFILE_BACKGROUND = "#83DDC5";
export const FRIEND_BACKGROUND = "#F47FFF";
export const MESSAGE_BACKGROUND = "#FFDE4D";
export const MENTION_BACKGROUND = "#DA373C";
export const REPLY_BACKGROUND = "#3498DB";
@@ -0,0 +1,297 @@
// Metro module 15284 (f15285).
import NotificationCenterItemsStore from "./NotificationCenterItemsStore";
import { Endpoints } from "../../Constants";
import Dispatcher from "../../Dispatcher";
import TrackedHTTPUtils from "../../utils/TrackedHTTPUtils";
import { NetworkActionNames } from "../../_bundle/Module503";
import { exact } from "../../_bundle/Module1385";
import { isMentionItem, isRemoteAcked } from "./NotificationCenterUtils";
import { HTTP } from "../../_bundle/sendRequest";
import { NotificationCenterAckedBeforeId } from "../user_settings/UserSettings";
function $mk116909($env) {
return (a0) => {
const r4 = a0.body?.items || [];
const r6 = $env;
const items = r4.map((item) => item.type);
return exact({
page: r6[2],
items,
item_count: items.length
});
};
}
let env10861 = {};
export async function markNotificationCenterRemoteItemAcked(c27983_0) {
let c27983_4 = 0;
let c30859_0;
L10: {
try {
c30859_0 = c27983_0;
c27983_4 = 1;
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_ACK",
optimistic: true,
ids: [c27983_0]
});
await HTTP.post({
url: Endpoints.NOTIF_CENTER_ITEMS_ACK(c27983_0),
rejectWithError: true
});
c27983_4 = 0;
} catch ($e) {
let r8 = $e;
if (c27983_4 !== 0) {
while (true) {
try {
c27983_4 = 0;
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_ACK_FAILURE",
ids: [c30859_0]
});
break L10;
} catch ($e) {
r8 = $e;
if (c27983_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export function setNotificationCenterActive(a0) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_SET_ACTIVE",
active: a0
});
}
export function setNotificationCenterTabFocused(a0) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_TAB_FOCUSED",
focused: a0
});
}
export function resetNotificationCenter() {
Dispatcher.dispatch({
type: "RESET_NOTIFICATION_CENTER"
});
}
export async function fetchNotificationCenterItems(c27982_0, c27982_1) {
let c27982_2, c27982_3, c27982_4;
let c27982_5 = 0;
const r14 = env10861;
L19: {
try {
let env30858;
c27982_3 = r14;
const r39 = env30858 = {
$parent: r14
};
c27982_2 = r39;
env30858[0] = c27982_0;
env30858[1] = c27982_1;
env30858[2] = void 0;
env30858[3] = void 0;
if (NotificationCenterItemsStore.loading) {
break L19;
}
await Dispatcher.dispatch({
type: "LOAD_NOTIFICATION_CENTER_ITEMS"
});
env30858[2] = Math.ceil(NotificationCenterItemsStore.items.length / env30858[0].limit);
const r78 = c27982_2;
c27982_5 = 1;
env30858[3] = await TrackedHTTPUtils.get({
url: Endpoints.NOTIF_CENTER_ITEMS(),
trackedActionData: {
event: NetworkActionNames.NOTIFICATION_CENTER_PAGE_FETCH,
properties: $mk116909(r78)
},
query: {
...env30858[0]
},
rejectWithError: true
});
const r118 = env30858[1];
if (r118 != null) {
r118();
}
await Dispatcher.dispatch({
type: "LOAD_NOTIFICATION_CENTER_ITEMS_SUCCESS",
items: env30858[3].body.items,
cursor: env30858[3].body.cursor,
hasMore: env30858[3].body.has_more
});
c27982_5 = 0;
} catch ($e) {
const r37 = $e;
let r8 = r37;
c27982_4 = r37;
if (c27982_5 !== 0) {
while (true) {
try {
c27982_5 = 0;
const r165 = env30858[1];
if (r165 != null) {
r165();
}
await Dispatcher.dispatch({
type: "LOAD_NOTIFICATION_CENTER_ITEMS_FAILURE"
});
} catch (r161) {
r8 = r161;
c27982_4 = r161;
if (c27982_5 === 0) {
break;
}
continue;
}
return void 0;
}
}
throw r8;
}
return void 0;
}
}
export function markNotificationCenterItemAcked(a0) {
if (a0.local_id != null) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_LOCAL_ACK",
localIds: [a0.local_id]
});
} else if (isMentionItem(a0)) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_ACK",
optimistic: true,
ids: [a0.id]
});
} else {
markNotificationCenterRemoteItemAcked(a0.id);
}
}
export function markNotificationCenterLocalItemsAcked(a0) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_LOCAL_ACK",
localIds: a0
});
}
export function markNotificationCenterMentionAcked(a0) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_ACK",
optimistic: true,
ids: [a0]
});
}
export async function bulkMarkNotificationCenterItemsAcked(c27984_0) {
let c27984_1, c27984_2, c27984_3;
let c27984_4 = 0;
const r11 = env10861;
L10: {
try {
let env30860;
c27984_2 = r11;
const r26 = env30860 = {
$parent: r11
};
c27984_1 = r26;
env30860[0] = void 0;
const ids = c27984_0.map((item) => item.id);
env30860[0] = ids;
c27984_4 = 1;
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_ACK",
optimistic: true,
ids
});
await HTTP.post({
url: Endpoints.NOTIF_CENTER_ITEMS_BULK_ACK,
query: {
item_ids: c27984_0.filter((item) => item.local_id == null || isMentionItem(item)).map((item) => item.id)
},
rejectWithError: true
});
c27984_4 = 0;
} catch ($e) {
const r24 = $e;
let r8 = r24;
c27984_3 = r24;
if (c27984_4 !== 0) {
while (true) {
try {
c27984_4 = 0;
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEMS_ACK_FAILURE",
ids: env30860[0]
});
break L10;
} catch (r70) {
r8 = r70;
c27984_3 = r70;
if (c27984_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function deleteNotificationCenterItem(c27985_0) {
let c27985_3;
let c27985_4 = 0;
let c30861_0, c30861_1;
try {
c30861_0 = c27985_0;
const setting = NotificationCenterAckedBeforeId.getSetting();
c27985_4 = 1;
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEM_DELETE",
id: c27985_0.id
});
await TrackedHTTPUtils.delete({
url: Endpoints.NOTIF_CENTER_ITEMS(c27985_0.id),
body: {
item_type: isMentionItem(c27985_0) ? "mention" : "regular"
},
trackedActionData: {
event: NetworkActionNames.NOTIFICATION_CENTER_ITEM_DELETE,
properties: {
notification_center_id: c27985_0.id,
acked: isRemoteAcked(c27985_0, setting),
item_type: c27985_0.type
}
},
rejectWithError: false
});
c27985_4 = 0;
} catch ($e) {
const r31 = $e;
let r8 = r31;
c27985_3 = r31;
if (c27985_4 !== 0) {
while (true) {
try {
const r99 = c27985_3;
c27985_4 = 0;
c30861_1 = r99;
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_ITEM_DELETE_FAILURE",
item: c30861_0
});
throw c30861_1;
} catch (r95) {
r8 = r95;
c27985_3 = r95;
if (c27985_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
@@ -0,0 +1,444 @@
// Metro module 5925 (f5926).
import ExperimentStore from "../experiments/ExperimentStore";
import { isGuildEventEnded } from "../guild_scheduled_events/GuildScheduledEventStore";
import MessageRecord from "../../records/MessageRecord";
import RelationshipStore from "../../stores/RelationshipStore";
import UserStore from "../../stores/UserStore";
import { RelationshipTypes } from "../../Constants";
import { ItemEnum, NotificationCenterItems, NotificationCenterLocalItems } from "./NotificationCenterItemsTypes";
import { createMessageRecord } from "../messages/MessageRecordUtils";
import { incomingFriendRequestLocalItem, incomingGameFriendRequestLocalItem, mobileNativeUpdateAvailableLocalItem } from "./NotificationCenterUtils";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
function $mk77386($env) {
return (a0) => {
const r3 = $env;
return r3[0].includes(a0.id) ? {
...a0,
acked: r3[1]
} : a0;
};
}
function $mk77389($env) {
return (a0) => {
const type = a0.type;
const r1 = $env.$parent;
return type === (0, r1[0])(r1[2][6]).NotificationCenterItems.GUILD_SCHEDULED_EVENT_STARTED ? a0.guild_scheduled_event_id === $env[0].id ? {
...a0,
disable_action: true
} : a0 : a0;
};
}
let toNotificationCenterItem, c3711_12;
let env3711 = {};
const _validate = function _validate(a0) {
return a0.id != null && a0.type != null;
};
toNotificationCenterItem = function toNotificationCenterItem(a0) {
if (a0.item_enum === ItemEnum.FIRST_MESSAGE && a0.type === NotificationCenterItems.LIFECYCLE_ITEM) {
a0.deeplink = "https://discord.com/feature/composeMessage";
}
return {
...a0,
kind: "notification-center-item",
message: a0.message != null ? createMessageRecord(a0.message) : void 0,
applicationId: a0.application != null ? a0.application.id : void 0
};
};
const handleAddItem = function handleAddItem(a0) {
let r15;
if (a0.type === "NOTIFICATION_CENTER_ITEM_CREATE") {
const item = a0.item;
if (item.item_enum === ItemEnum.FIRST_MESSAGE && item.type === NotificationCenterItems.LIFECYCLE_ITEM) {
item.deeplink = "https://discord.com/feature/composeMessage";
}
r15 = {
...item,
kind: "notification-center-item",
message: item.message != null ? createMessageRecord(item.message) : void 0,
applicationId: item.application != null ? item.application.id : void 0
};
} else {
r15 = a0.item;
}
if (env3711[9].initialized && r15.id != null && r15.type != null && !env3711[9].notifCenterIds.has(r15.id)) {
env3711[9].notifCenterIds.add(r15.id);
const r56 = env3711[9];
r56.notifCenterItems = [r15, ...r56.notifCenterItems];
env3711[9].notifCenterItems.sort((a, b) => SnowflakeUtils.compare(b.id, a.id));
return void 0;
}
return false;
};
const handleRelationshipAddOrUpdate = function handleRelationshipAddOrUpdate({ relationship }) {
const { id, type, isSpamRequest, userIgnored, user, since, originApplicationId } = relationship;
if (type === RelationshipTypes.PENDING_INCOMING && !isSpamRequest && !userIgnored) {
if (since == null) {
return null;
}
if (user != null) {
const user2 = UserStore.getUser(user.id);
if (user2 != null) {
const r24 = env3711[9];
r24.notifCenterLocalItems = [...r24.notifCenterLocalItems, incomingFriendRequestLocalItem(user2, since, originApplicationId)];
}
}
}
if (!(type !== RelationshipTypes.FRIEND || relationship.user == null || userIgnored)) {
const r35 = env3711[9];
r35.notifCenterLocalItems = r35.notifCenterLocalItems.map((notifCenterLocalItem) => {
const INCOMING_FRIEND_REQUESTS = NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS;
const id4 = relationship.user.id;
return notifCenterLocalItem.type === INCOMING_FRIEND_REQUESTS && notifCenterLocalItem.other_user?.id === id4 ? {
...notifCenterLocalItem,
acked: true,
forceUnacked: false,
local_id: `incoming_friend_requests_accepted_${user.id}_${notifCenterLocalItem.id}`,
type: NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED
} : notifCenterLocalItem;
});
}
if (type === RelationshipTypes.BLOCKED || userIgnored) {
const r42 = env3711[9];
r42.notifCenterLocalItems = r42.notifCenterLocalItems.filter((notifCenterLocalItem) => !(notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS && notifCenterLocalItem.other_user?.id === id || notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED && notifCenterLocalItem.other_user?.id === id || notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS && notifCenterLocalItem.other_user?.id === id || notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED && notifCenterLocalItem.other_user?.id === id));
}
};
env3711[9] = {
loading: false,
initialized: false,
errored: false,
isDataStale: false,
notifCenterItems: [],
staleNotifCenterItems: [],
notifCenterIds: new Set(),
notifCenterLocalItems: [],
paginationHasMore: true,
paginationCursor: void 0,
notifCenterActive: false,
notifCenterTabFocused: false
};
class NotificationCenterItemsStore extends Module589.PersistedStore {
static displayName = "NotificationCenterItemsStore";
static persistKey = "NotificationCenterItemsStore_v2";
constructor() {
super(...arguments);
}
initialize(a0) {
this.waitFor(UserStore, RelationshipStore, ExperimentStore);
if (a0 != null) {
const staleNotifCenterItems = a0.notifCenterItems.map(function(notifCenterItem) {
return {
...notifCenterItem,
message: notifCenterItem.message != null ? new MessageRecord(notifCenterItem.message) : void 0
};
});
if (staleNotifCenterItems.length > 0) {
env3711[9] = {
...env3711[9],
initialized: true,
isDataStale: true,
notifCenterItems: [],
staleNotifCenterItems
};
}
}
}
getState() {
const pack = function pack(a0) {
return {
...a0,
message: a0.message != null ? a0.message.toJS() : void 0
};
};
return {
...env3711[9],
notifCenterItems: env3711[9].notifCenterItems.map(pack),
staleNotifCenterItems: env3711[9].staleNotifCenterItems.map(pack)
};
}
get loading() {
return env3711[9].loading;
}
get initialized() {
return env3711[9].initialized;
}
get items() {
const isDataStale = env3711[9].isDataStale;
const r3 = env3711[9];
return isDataStale ? r3.staleNotifCenterItems : r3.notifCenterItems;
}
get hasMore() {
return env3711[9].paginationHasMore;
}
get cursor() {
return env3711[9].paginationCursor;
}
get errored() {
return env3711[9].errored;
}
get active() {
return env3711[9].notifCenterActive;
}
get localItems() {
return env3711[9].notifCenterLocalItems;
}
get tabFocused() {
return env3711[9].notifCenterTabFocused;
}
}
c3711_12 = NotificationCenterItemsStore;
const r94 = new NotificationCenterItemsStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
const notifCenterLocalItems = [];
let c15277_0 = notifCenterLocalItems;
let c15277_1 = new Set();
a0.relationships.forEach(({ id: id4, type, since, is_spam_request, user_ignored, origin_application_id }) => {
if (user_ignored) {
c15277_1.add(id4);
}
if (type === RelationshipTypes.PENDING_INCOMING && !is_spam_request && !user_ignored && since != null) {
const user2 = UserStore.getUser(id4);
if (user2 == null) {
return null;
}
c15277_0.push(incomingFriendRequestLocalItem(user2, since, origin_application_id));
return void 0;
}
return null;
});
a0.gameRelationships.forEach(({ type, id: id4, application_id, since }) => {
if (type === RelationshipTypes.PENDING_INCOMING && !c15277_1.has(id4)) {
const user2 = UserStore.getUser(id4);
if (user2 != null) {
c15277_0.push(incomingGameFriendRequestLocalItem(user2, since, application_id));
}
}
});
a0.guilds.forEach((guild) => {
guild.guild_scheduled_events.forEach((guild_scheduled_event) => {
let env29635;
const r1 = env29635 = {
$parent: env3711
};
env29635[0] = guild_scheduled_event;
if ((0, isGuildEventEnded)(guild_scheduled_event)) {
const r6 = env3711[9];
r6.notifCenterItems = r6.notifCenterItems.map($mk77389(r1));
}
});
});
env3711[9].notifCenterLocalItems = notifCenterLocalItems;
},
LOGOUT: () => {
let keepLocalItems = ({}).keepLocalItems;
if (keepLocalItems === void 0) {
keepLocalItems = false;
}
env3711[9] = {
loading: false,
initialized: false,
errored: false,
isDataStale: false,
notifCenterItems: [],
staleNotifCenterItems: [],
notifCenterIds: new Set(),
notifCenterLocalItems: keepLocalItems ? env3711[9].notifCenterLocalItems : [],
paginationHasMore: true,
paginationCursor: void 0,
notifCenterActive: false,
notifCenterTabFocused: false
};
},
NOTIFICATION_CENTER_ITEMS_ACK: function handleAck({ ids }) {
let env15278;
const r3 = env15278 = {};
env15278[0] = ids;
env15278[1] = true;
const r7 = env3711[9];
r7.notifCenterItems = r7.notifCenterItems.map($mk77386(r3)).filter(_validate);
},
NOTIFICATION_CENTER_ITEMS_ACK_FAILURE: function handleAckFailure({ ids }) {
let env15279;
const r3 = env15279 = {};
env15279[0] = ids;
env15279[1] = false;
const r7 = env3711[9];
r7.notifCenterItems = r7.notifCenterItems.map($mk77386(r3)).filter(_validate);
},
GUILD_SCHEDULED_EVENT_UPDATE: function handleGuildScheduledEventUpdate({ guildScheduledEvent }) {
let env15280;
const r5 = env15280 = {
$parent: env3711
};
env15280[0] = guildScheduledEvent;
if ((0, isGuildEventEnded)(guildScheduledEvent)) {
const r7 = env3711[9];
r7.notifCenterItems = r7.notifCenterItems.map($mk77389(r5));
}
},
NOTIFICATION_CENTER_ITEM_CREATE: handleAddItem,
NOTIFICATION_CENTER_ITEM_DELETE: function handleDelete({ id: id2 }) {
if (env3711[9].notifCenterIds.has(id2)) {
env3711[9].notifCenterIds.delete(id2);
const r13 = env3711[9];
r13.notifCenterItems = r13.notifCenterItems.filter((notifCenterItem) => notifCenterItem.id !== id2);
return void 0;
}
return false;
},
NOTIFICATION_CENTER_ITEM_DELETE_FAILURE: handleAddItem,
LOAD_NOTIFICATION_CENTER_ITEMS: function handleLoad() {
env3711[9].loading = true;
},
LOAD_NOTIFICATION_CENTER_ITEMS_FAILURE: function handleLoadFailure() {
env3711[9].loading = false;
env3711[9].initialized = true;
env3711[9].errored = true;
},
LOAD_NOTIFICATION_CENTER_ITEMS_SUCCESS: function handleLoadSuccess({ items: items2, hasMore: hasMore2, cursor: cursor2 }) {
if (env3711[9].loading) {
env3711[9].loading = false;
env3711[9].initialized = true;
env3711[9].errored = false;
env3711[9].isDataStale = false;
if (!(cursor2 != null && env3711[9].notifCenterIds.has(cursor2))) {
env3711[9].paginationHasMore = items2.length > 0 && hasMore2;
env3711[9].paginationCursor = items2.length > 0 ? cursor2 : void 0;
}
const r29 = env3711[9];
r29.notifCenterItems = [...r29.notifCenterItems, ...items2.map(toNotificationCenterItem).filter((item) => !env3711[9].notifCenterIds.has(item.id))];
env3711[9].notifCenterItems.sort((a, b) => SnowflakeUtils.compare(b.id, a.id));
items2.forEach((item) => env3711[9].notifCenterIds.add(item.id));
}
},
RESET_NOTIFICATION_CENTER: () => {
let keepLocalItems = ({
keepLocalItems: true
}).keepLocalItems;
if (keepLocalItems === void 0) {
keepLocalItems = false;
}
env3711[9] = {
loading: false,
initialized: false,
errored: false,
isDataStale: false,
notifCenterItems: [],
staleNotifCenterItems: [],
notifCenterIds: new Set(),
notifCenterLocalItems: keepLocalItems ? env3711[9].notifCenterLocalItems : [],
paginationHasMore: true,
paginationCursor: void 0,
notifCenterActive: false,
notifCenterTabFocused: false
};
},
NOTIFICATION_CENTER_SET_ACTIVE: function handleSetActive(a0) {
env3711[9].notifCenterActive = a0.active;
},
NOTIFICATION_CENTER_TAB_FOCUSED: function handleTabFocused(a0) {
env3711[9].notifCenterTabFocused = a0.focused;
},
RELATIONSHIP_ADD: handleRelationshipAddOrUpdate,
RELATIONSHIP_UPDATE: handleRelationshipAddOrUpdate,
RELATIONSHIP_REMOVE: function handleRelationshipRemove(c15282_0) {
const r6 = env3711[9];
r6.notifCenterLocalItems = r6.notifCenterLocalItems.filter((notifCenterLocalItem) => {
const INCOMING_FRIEND_REQUESTS = NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS;
const id4 = c15282_0.relationship.id;
const r0 = notifCenterLocalItem.type === INCOMING_FRIEND_REQUESTS && notifCenterLocalItem.other_user?.id === id4;
let r20 = !r0;
if (!r0) {
const INCOMING_FRIEND_REQUESTS_ACCEPTED = NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED;
const id5 = c15282_0.relationship.id;
r20 = !(notifCenterLocalItem.type === INCOMING_FRIEND_REQUESTS_ACCEPTED && notifCenterLocalItem.other_user?.id === id5);
}
return r20;
});
},
GAME_RELATIONSHIP_ADD: function handleGameRelationshipAddOrUpdate({ gameRelationship }) {
const { id: id3, type, since, applicationId } = gameRelationship;
if (RelationshipStore.isBlockedOrIgnored(id3)) {
return false;
}
if (type === RelationshipTypes.PENDING_INCOMING) {
const user2 = UserStore.getUser(id3);
if (since != null && user2 != null) {
const r30 = env3711[9];
r30.notifCenterLocalItems = [...r30.notifCenterLocalItems, incomingGameFriendRequestLocalItem(user2, since, applicationId)];
}
} else {
if (type !== RelationshipTypes.FRIEND) {
return false;
}
const r21 = env3711[9];
r21.notifCenterLocalItems = r21.notifCenterLocalItems.map((notifCenterLocalItem) => notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS && notifCenterLocalItem.other_user?.id === id3 && notifCenterLocalItem.applicationId === applicationId ? {
...notifCenterLocalItem,
acked: true,
forceUnacked: false,
local_id: `incoming_game_friend_requests_accepted_${id3}_${notifCenterLocalItem.id}`,
type: NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED
} : notifCenterLocalItem);
}
},
GAME_RELATIONSHIP_REMOVE: function handleGameRelationshipRemove({ userId, applicationId: applicationId2 }) {
const r7 = env3711[9];
r7.notifCenterLocalItems = r7.notifCenterLocalItems.filter((notifCenterLocalItem) => {
const r0 = notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS && notifCenterLocalItem.other_user?.id === userId && notifCenterLocalItem.applicationId === applicationId2;
return r0 ? !r0 : !(notifCenterLocalItem.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED && notifCenterLocalItem.other_user?.id === userId && notifCenterLocalItem.applicationId === applicationId2);
});
},
NOTIFICATION_CENTER_ITEM_COMPLETED: function handleCompleted({ item_enum }) {
const r7 = env3711[9];
r7.notifCenterItems = r7.notifCenterItems.map((notifCenterItem) => notifCenterItem.item_enum === item_enum ? {
...notifCenterItem,
completed: true,
acked: true
} : notifCenterItem).filter(_validate);
},
SET_RECENT_MENTIONS_FILTER: () => {
let keepLocalItems = ({
keepLocalItems: true
}).keepLocalItems;
if (keepLocalItems === void 0) {
keepLocalItems = false;
}
env3711[9] = {
loading: false,
initialized: false,
errored: false,
isDataStale: false,
notifCenterItems: [],
staleNotifCenterItems: [],
notifCenterIds: new Set(),
notifCenterLocalItems: keepLocalItems ? env3711[9].notifCenterLocalItems : [],
paginationHasMore: true,
paginationCursor: void 0,
notifCenterActive: false,
notifCenterTabFocused: false
};
},
MOBILE_NATIVE_UPDATE_CHECK_FINISHED: function handleMobileNativeUpdate({ newBuild }) {
let c15286_0;
c15286_0 = void 0;
if (newBuild !== null) {
const r16 = mobileNativeUpdateAvailableLocalItem(newBuild);
c15286_0 = r16;
if (env3711[9].notifCenterLocalItems.find((notifCenterLocalItem) => notifCenterLocalItem.local_id === c15286_0.local_id) === void 0) {
const r21 = env3711[9];
r21.notifCenterLocalItems = [...r21.notifCenterLocalItems.filter((notifCenterLocalItem) => notifCenterLocalItem.type !== c15286_0.type), r16];
}
}
},
APPLICATIONS_FETCH_SUCCESS: function handleFetchApplicationsSuccess({ unknownApplicationIds }) {
let c15287_0;
c15287_0 = void 0;
if (unknownApplicationIds != null) {
c15287_0 = new Set(unknownApplicationIds);
const r13 = env3711[9];
r13.notifCenterLocalItems = r13.notifCenterLocalItems.filter((notifCenterLocalItem) => notifCenterLocalItem.applicationId == null || !c15287_0.has(notifCenterLocalItem.applicationId));
}
}
});
export default r94;
@@ -0,0 +1,58 @@
// Metro module 5926 (f5927).
const r8 = {
LANDING: "notification_center_landing"
};
const r7 = {
UPDATE_PROFILE: 0,
0: "UPDATE_PROFILE",
FIND_FRIENDS: 1,
1: "FIND_FRIENDS",
ADD_FRIEND: 2,
2: "ADD_FRIEND",
FIRST_MESSAGE: 3,
3: "FIRST_MESSAGE"
};
const r22 = {
MARK_ALL_READ: "mark_all_read",
CLICKED: "clicked",
FRIEND_REQUESTS_BUTTON_CLICK: "friend_requests_button_click",
ACTION_BUTTON: "action_button"
};
const r27 = {
ForYou: "ForYou",
Mentions: "Mentions",
MessageReminders: "MessageReminders"
};
const r31 = {
GO_LIVE_PUSH: "go_live_push",
FRIEND_REQUEST_ACCEPTED: "friend_request_accepted",
FRIEND_REQUEST_PENDING: "friend_request_pending",
FRIEND_SUGGESTION_CREATED: "friend_suggestion_created",
FRIEND_REQUEST_REMINDER: "friend_request_reminder",
DM_FRIEND_NUDGE: "dm_friend_nudge",
RECENT_MENTION: "recent_mention",
REPLY_MENTION: "reply_mention",
GUILD_SCHEDULED_EVENT_STARTED: "scheduled_guild_event_started",
SYSTEM_DEMO: "system_demo",
MISSED_MESSAGES: "missed_messages",
TOP_MESSAGES: "top_messages",
LIFECYCLE_ITEM: "lifecycle_item",
TRENDING_CONTENT: "trending_content",
GAME_FRIEND_REQUEST_ACCEPTED: "game_friend_request_accepted",
REACTION_SENT: "reaction_sent",
REFERRAL_PROGRAM_ENTRYPOINT_REMINDER: "referral_program_entrypoint_reminder"
};
const r49 = {
INCOMING_FRIEND_REQUESTS: "INCOMING_FRIEND_REQUESTS",
INCOMING_FRIEND_REQUESTS_ACCEPTED: "INCOMING_FRIEND_REQUESTS_ACCEPTED",
FRIEND_REQUESTS_GROUPED: "FRIEND_REQUESTS_GROUPED",
MOBILE_NATIVE_UPDATE_AVAILABLE: "MOBILE_NATIVE_UPDATE_AVAILABLE",
INCOMING_GAME_FRIEND_REQUESTS: "INCOMING_GAME_FRIEND_REQUESTS",
INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED: "INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED"
};
export { r8 as NotificationCenterScenes };
export { r7 as ItemEnum };
export { r22 as NotificationCenterActionTypes };
export { r27 as NotificationCenterTabs };
export { r31 as NotificationCenterItems };
export { r49 as NotificationCenterLocalItems };
@@ -0,0 +1,102 @@
// Metro module 15282 (f15283).
import RecentMentionsStore from "../inbox/RecentMentionsStore";
import Durations from "../../utils/Durations";
import Module589 from "../../_bundle/Module589";
import { NotificationCenterTabs } from "./NotificationCenterItemsTypes";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Dispatcher from "../../Dispatcher";
let c10859_5, c10859_6;
const handleLoadFinished = function handleLoadFinished() {
c10859_6.hasNewMentions = false;
c10859_6.isDataStale = false;
c10859_6.isRefreshing = false;
};
c10859_5 = 90 * Durations.Millis.DAY;
c10859_6 = {
tab: null,
localItemAcks: {},
hasNewMentions: false,
isDataStale: false,
isRefreshing: false
};
class NotificationCenterStore extends Module589.PersistedStore {
static displayName = "NotificationCenterStore";
static persistKey = "NotificationCenterStore";
initialize(a0) {
this.waitFor(RecentMentionsStore);
if (a0 != null) {
c10859_6 = a0;
let localItemAcks = a0.localItemAcks;
if (localItemAcks == null) {
localItemAcks = {};
}
a0.localItemAcks = (function purge(a0) {
const r0 = {};
for (const item of Object.entries(a0)) {
const [r32, r33] = item;
if (Date.now() - r33 < c10859_5) {
r0[r32] = r33;
}
}
return r0;
})(localItemAcks);
c10859_6.isDataStale = true;
}
}
getState() {
return c10859_6;
}
getTab() {
let tab = c10859_6.tab;
if (tab == null) {
tab = NotificationCenterTabs.ForYou;
}
return tab;
}
isLocalItemAcked(a0) {
return a0.local_id != null && (c10859_6.localItemAcks[a0.local_id] != null || SnowflakeUtils.age(a0.id) > c10859_5);
}
hasNewMentions() {
return c10859_6.hasNewMentions;
}
isDataStale() {
return c10859_6.isDataStale;
}
isRefreshing() {
return c10859_6.isRefreshing;
}
shouldReload() {
return c10859_6.hasNewMentions || c10859_6.isDataStale || c10859_6.isRefreshing;
}
}
const notificationCenterStore = new NotificationCenterStore(Dispatcher, {
MESSAGE_CREATE: function handleMessageCreate(a0) {
if (RecentMentionsStore.hasMention(a0.message.id)) {
c10859_6.hasNewMentions = true;
}
},
NOTIFICATION_CENTER_SET_TAB: function handleSetTab(a0) {
c10859_6 = {
...c10859_6,
tab: a0.tab
};
},
NOTIFICATION_CENTER_ITEMS_LOCAL_ACK: function handleAck(a0) {
a0.localIds.forEach((localId) => {
const localItemAcks = {
...c10859_6.localItemAcks
};
localItemAcks[localId] = Date.now();
c10859_6 = {
...c10859_6,
localItemAcks
};
});
},
NOTIFICATION_CENTER_REFRESH: function handleRefreshData() {
c10859_6.isRefreshing = true;
},
LOAD_NOTIFICATION_CENTER_ITEMS_FAILURE: handleLoadFinished,
LOAD_NOTIFICATION_CENTER_ITEMS_SUCCESS: handleLoadFinished
});
export default notificationCenterStore;
@@ -0,0 +1,18 @@
// Metro module 15286 (f15287).
import Dispatcher from "../../Dispatcher";
export function setTab(a0) {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_SET_TAB",
tab: a0
});
}
export function clearNotificationGuildMentions() {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_CLEAR_GUILD_MENTIONS"
});
}
export function refreshNotifications() {
Dispatcher.dispatch({
type: "NOTIFICATION_CENTER_REFRESH"
});
}
@@ -0,0 +1,56 @@
// Metro module 5927 (f5928).
import getTimestampString, { getAbbreviatedFormatter, getFullFormatter } from "./getTimestampString";
import { NOTIFICATION_CENTER_ACKED_BEFORE_ID_UNSET } from "../user_settings/UserSettings";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import { NotificationCenterLocalItems, NotificationCenterItems } from "./NotificationCenterItemsTypes";
export function getRelativeTimestamp(a0, r4 = true) {
return getTimestampString({
since: a0,
getFormatter: r4 ? getAbbreviatedFormatter : getFullFormatter
});
}
export function isRemoteAcked(a0, a1) {
return a0.acked || a1 !== NOTIFICATION_CENTER_ACKED_BEFORE_ID_UNSET && SnowflakeUtils.compare(a1, a0.id) >= 0;
}
export function incomingFriendRequestLocalItem(a0, a1, a2) {
const id = SnowflakeUtils.fromTimestamp(new Date(a1).getTime());
return {
acked: false,
forceUnacked: true,
other_user: a0,
kind: "notification-center-item",
local_id: `incoming_friend_requests_${a0.id}_${id}`,
deeplink: `https://discord.com/users/${a0.id}`,
type: NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS,
id,
applicationId: a2
};
}
export function incomingGameFriendRequestLocalItem(a0, a1, a2) {
const id = SnowflakeUtils.fromTimestamp(new Date(a1).getTime());
return {
acked: false,
forceUnacked: true,
other_user: a0,
kind: "notification-center-item",
local_id: `incoming_game_friend_requests_${a0.id}_${id}`,
deeplink: `https://discord.com/users/${a0.id}`,
type: NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS,
id,
applicationId: a2
};
}
export function mobileNativeUpdateAvailableLocalItem(a0) {
return {
acked: false,
enableBadge: true,
id: SnowflakeUtils.fromTimestamp(new Date().getTime()),
kind: "notification-center-item",
local_id: `mobile_update_available_${a0.build}`,
type: NotificationCenterLocalItems.MOBILE_NATIVE_UPDATE_AVAILABLE,
deeplink: a0.urls.install.toString()
};
}
export function isMentionItem(a0) {
return a0.type === NotificationCenterItems.RECENT_MENTION || a0.type === NotificationCenterItems.REPLY_MENTION;
}
@@ -0,0 +1,157 @@
// Metro module 15294 (f15295).
import GuildScheduledEventStore, { isGuildEventEnded } from "../guild_scheduled_events/GuildScheduledEventStore";
import GuildStore from "../../stores/GuildStore";
import RelationshipStore from "../../stores/RelationshipStore";
import UserStore from "../../stores/UserStore";
import { EMPTY_STRING_SNOWFLAKE_ID, RelationshipTypes } from "../../Constants";
import { intl, t } from "../../intl/index.native";
import UserUtils from "../../utils/UserUtils";
import { NotificationCenterLocalItems, NotificationCenterItems } from "./NotificationCenterItemsTypes";
import { isNullOrEmpty } from "../../utils/StringUtils";
import Module38 from "../../_bundle/Module38";
function $mk96027($env) {
return () => {
const r1 = $env;
return (0, r1[1])(r1[0]);
};
}
let c10869_10 = /[\\`*_~|<>[\]:]/g;
export default function getNotificationCenterItemBody({ item, renderApplication }) {
let r229, r236;
let r12 = item.other_user?.id;
if (r12 == null) {
r12 = EMPTY_STRING_SNOWFLAKE_ID;
}
const name2 = UserUtils.getName(UserStore.getUser(item.other_user?.id));
const user = name2 !== void 0 ? name2.replace(c10869_10, "\\$&") : void 0;
const { applicationId, type } = item;
if (NotificationCenterLocalItems.FRIEND_REQUESTS_GROUPED === type) {
const other_users = item.other_users;
const name4 = UserUtils.getName(UserStore.getUser(other_users == null ? void 0 : other_users[0]?.id));
const user2 = name4 !== void 0 ? name4.replace(c10869_10, "\\$&") : void 0;
const other_users2 = item.other_users;
const name5 = UserUtils.getName(UserStore.getUser(other_users2 == null ? void 0 : other_users2[1]?.id));
const user22 = name5 !== void 0 ? name5.replace(c10869_10, "\\$&") : void 0;
const r290 = Math;
let r294 = item.other_users?.length;
if (r294 == null) {
r294 = 0;
}
return intl.format(t.g5xyIC, {
user: user2,
user2: user22,
count: r290.max(r294 - 2, 0)
});
}
if (NotificationCenterLocalItems.MOBILE_NATIVE_UPDATE_AVAILABLE === type) {
const local_id = item.local_id;
let r248 = local_id == null ? void 0 : local_id.split("_").pop();
if (r248 == null) {
r248 = "unknown";
}
return `Update to build ${r248} available!`;
}
if (NotificationCenterItems.FRIEND_SUGGESTION_CREATED === type) {
if (RelationshipStore.getRelationshipType(r12) === RelationshipTypes.PENDING_OUTGOING) {
r236 = intl.format(t.gZVTy2, {
user
});
} else {
r236 = item.body;
if (r236 == null) {
r236 = "";
}
}
return r236;
}
if (NotificationCenterItems.GUILD_SCHEDULED_EVENT_STARTED === type) {
const guild_scheduled_event_id = item.guild_scheduled_event_id;
let r191 = guild_scheduled_event_id != null ? GuildScheduledEventStore.getGuildScheduledEvent(guild_scheduled_event_id) : null;
const name3 = r191?.name;
const name = GuildStore.getGuild(r191?.guild_id)?.name;
if (r191 == null) {
r191 = void 0;
}
const isGuildEventEnded2 = isGuildEventEnded(r191);
if (!isNullOrEmpty(name) && (!isNullOrEmpty(name3) && isGuildEventEnded2)) {
r229 = intl.format(t.AyvfXR, {
event_name: name3 !== void 0 ? name3.replace(c10869_10, "\\$&") : void 0,
guild_name: name !== void 0 ? name.replace(c10869_10, "\\$&") : void 0
});
} else {
let body2 = item.body;
if (body2 == null) {
body2 = "";
}
r229 = body2;
}
return r229;
}
if (NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS === type) {
let env21859;
const r171 = t["9Dgf1L"];
const uIomXw = t.uIomXw;
const r176 = env21859 = {};
env21859[0] = applicationId;
env21859[1] = renderApplication;
return applicationId != null ? intl.format(r171, {
username: user,
applicationName: $mk96027(r176)
}) : intl.format(uIomXw, {
username: user
});
}
if (NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED === type) {
let env21858;
const nnC1q9 = t.nnC1q9;
const r154 = t["5Uzkdp"];
const r155 = env21858 = {};
env21858[0] = applicationId;
env21858[1] = renderApplication;
return applicationId != null ? intl.format(nnC1q9, {
username: user,
applicationName: $mk96027(r155)
}) : intl.format(r154, {
username: user
});
}
if (NotificationCenterItems.FRIEND_REQUEST_ACCEPTED === type) {
let env21857;
const jXlYiF = t.jXlYiF;
const McYRBk = t.McYRBk;
const r134 = env21857 = {};
env21857[0] = applicationId;
env21857[1] = renderApplication;
return applicationId != null ? intl.format(jXlYiF, {
username: user,
applicationName: $mk96027(r134)
}) : intl.format(McYRBk, {
username: user
});
}
if (NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED === type) {
Module38(applicationId != null, `Expected application id for ${item.type}`);
return intl.format(t["BB/0vn"], {
username: user,
applicationName: () => renderApplication(applicationId)
});
}
if (NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS === type) {
Module38(applicationId != null, `Expected application id for ${item.type}`);
return intl.format(t["7cqOLI"], {
username: user,
applicationName: () => renderApplication(applicationId)
});
}
if (NotificationCenterItems.GAME_FRIEND_REQUEST_ACCEPTED === type) {
return applicationId == null ? item.body : intl.format(t.Wi64vN, {
username: user,
applicationName: () => renderApplication(applicationId)
});
}
let body = item.body;
if (body == null) {
body = "";
}
return body;
};
@@ -0,0 +1,48 @@
// Metro module 5928 (f5929).
import { intl, t } from "../../intl/index.native";
import Module3771 from "../../_bundle/Module3771";
let c3713_3, c3713_4;
const getDurationString = function getDurationString(a0) {
const seconds = a0.seconds;
const r8 = (0, a0.getFormatter)();
return seconds < 60 ? intl.formatToPlainString(r8.minutes, {
minutes: 1
}) : seconds < 3600 ? intl.formatToPlainString(r8.minutes, {
minutes: Math.floor(seconds / 60)
}) : seconds < 86400 ? intl.formatToPlainString(r8.hours, {
hours: Math.floor(seconds / 3600)
}) : seconds < c3713_3 ? intl.formatToPlainString(r8.days, {
days: Math.floor(seconds / 86400)
}) : seconds < c3713_4 ? intl.formatToPlainString(r8.months, {
months: Math.floor(seconds / c3713_3)
}) : intl.formatToPlainString(r8.years, {
years: Math.floor(seconds / c3713_4)
});
};
c3713_3 = 2592000;
c3713_4 = 31104000;
export default function getTimestampString({ since, getFormatter }) {
return getDurationString({
seconds: Module3771().diff(Module3771(since), "s"),
getFormatter
});
};
export function getAbbreviatedFormatter() {
return {
minutes: t["XIGt+W"],
hours: t.rhY1Rs,
days: t.GBLpQ8,
months: t.XzBNbS,
years: t.I1E8p6
};
}
export function getFullFormatter() {
return {
minutes: t["GqQ/Y9"],
hours: t.c5zfWZ,
days: t.amjnaI,
months: t.SoON3V,
years: t["12B3Re"]
};
}
export { getDurationString };
@@ -0,0 +1,41 @@
// Metro module 15318 (f15319).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { MailboxSpotIllustration } from "../../../design/assets/native";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
image: {
marginBottom: 16
},
container: {
paddingHorizontal: 48,
alignItems: "center",
justifyContent: "center"
},
headerText: {
fontSize: 18,
marginTop: 16,
marginBottom: 8
},
text: {
textAlign: "center"
}
});
export function ForYouEmptyState(props) {
const height = props.height;
const styles = useStyles();
return <View style={[styles.container, {
height
}]}>
<View style={styles.image}>
<MailboxSpotIllustration scale={0.75} />
</View>
<Text accessibilityRole="header" color="mobile-text-heading-primary" variant="heading-md/bold" style={[styles.text, styles.headerText]}>
{intl.string(t.MwjTvn)}
</Text>
<Text color="text-default" variant="text-md/medium" style={styles.text}>
{intl.string(t.AKBgPy)}
</Text>
</View>;
}
@@ -0,0 +1,12 @@
// Metro module 15307 (f15308).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
const useStyles = createStyles({
container: {
marginTop: Module712.space.PX_16
}
});
export function ForYouHoistedItemsHeader() {
return <View style={useStyles().container} />;
}
@@ -0,0 +1,617 @@
// Metro module 15293 (f15294).
import { useCallback } from "react";
import { View } from "react-native";
import ChannelStore from "../../../stores/ChannelStore";
import UserStore from "../../../stores/UserStore";
import { EMPTY_STRING_SNOWFLAKE_ID, MessageTypes, AnalyticEvents } from "../../../Constants";
import { jsx } from "react/jsx-runtime";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle, useAnimatedProps } from "../../reanimated/ReanimatedRexport";
import * as _timing from "../../../design/animation/reanimated/timing/timing";
import { Stack } from "../../../design/components/Stack/native/Stack.native";
import { Button } from "../../../design/components/Button/native/Button.native";
import { intl, t } from "../../../intl/index.native";
import { Text } from "../../../design/components/Text/native/Text";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import { useCanReplyToMessage } from "../../replies/canReplyToMessage";
import { sendWave } from "../../main_tabs_v2/native/friends/components/AddFriendsScreenUtils";
import parseURL from "../../../utils/native/parseURL";
import handleSupportedURL from "../../links/native/handleSupportedURL";
import PeopleUtils from "../../people/PeopleUtils";
import { NotificationCenterLocalItems, NotificationCenterItems, ItemEnum, NotificationCenterActionTypes } from "../NotificationCenterItemsTypes";
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
import RelationshipActionCreators from "../../../actions/RelationshipActionCreators";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { createShallowPendingReply } from "../../replies/PendingReplyActionCreators";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
function $mk96007($env) {
return () => {
const r1 = $env.$parent;
return (0, r1[0])(r1[2][8]).ComponentDispatch.dispatch(r1[9].TEXTAREA_FOCUS, $env[0]);
};
}
let IncomingFriendRequestActions, useStyles, c10868_15, c10868_17, c10868_18, c10868_19, c10868_20, c10868_21;
let env10868 = {};
const focusChatInput = function focusChatInput(a0) {
const r4 = a0 != null ? {
channelId: a0
} : void 0;
let env21852;
const r7 = env21852 = {
$parent: env10868
};
env21852[0] = r4;
setTimeout($mk96007(r7), 0);
};
IncomingFriendRequestActions = function IncomingFriendRequestActions(props) {
const { onAccept, onIgnore, onWavePress, pressed, compactMode } = props;
const styles = useStyles();
const sharedValue = useSharedValue(0);
const sharedValue2 = useSharedValue(-1);
const sharedValue3 = useSharedValue(-1);
const sharedValue4 = useSharedValue(-1);
const u = function u() {
return {
opacity: _timing.withTiming(pressed.get() ? 0 : 1, {
duration: 150
}),
pointerEvents: pressed.get() ? "none" : "auto"
};
};
u.__closure = {
withTiming: _timing.withTiming,
pressed
};
u.__workletHash = 100815030677;
u.__initData = c10868_17;
const animatedStyle = useAnimatedStyle(u);
const _ = function _() {
const r12 = pressed.get() ? 1 : sharedValue.get() / sharedValue2.get();
const r24 = sharedValue2.get() - sharedValue2.get() * r12;
const r1 = pressed.get() ? 0 : -r24 / 2;
return {
transform: [{
scaleX: _timing.withTiming(r12)
}, {
translateX: _timing.withTiming(r1)
}],
opacity: _timing.withTiming(pressed.get() ? 1 : 0),
pointerEvents: pressed.get() ? "auto" : "none"
};
};
_.__closure = {
pressed,
acceptButtonWidth: sharedValue,
buttonWidth: sharedValue2,
withTiming: _timing.withTiming
};
_.__workletHash = 12358515723480;
_.__initData = c10868_18;
const animatedStyle2 = useAnimatedStyle(_);
const E = () => ({
transform: [{
translateX: sharedValue3.get() / 2
}, {
translateY: sharedValue4.get() / 2
}]
});
E.__closure = {
waveWidth: sharedValue3,
waveHeight: sharedValue4
};
E.__workletHash = 667441788226;
E.__initData = c10868_19;
const animatedStyle3 = useAnimatedStyle(E);
const I = function I() {
return {
transform: [{
rotateZ: _ReanimatedRexport.withDelay(450, _ReanimatedRexport.withRepeat(_timing.withTiming(pressed.get() ? "8deg" : "-2deg", {
duration: 150,
easing: _ReanimatedRexport.Easing.inOut(_ReanimatedRexport.Easing.quad)
}), 4, true))
}, {
translateX: -sharedValue3.get() / 2
}, {
translateY: -sharedValue4.get() / 2
}]
};
};
I.__closure = {
withDelay: _ReanimatedRexport.withDelay,
withRepeat: _ReanimatedRexport.withRepeat,
withTiming: _timing.withTiming,
pressed,
Easing: _ReanimatedRexport.Easing,
waveWidth: sharedValue3,
waveHeight: sharedValue4
};
I.__workletHash = 498167545082;
I.__initData = c10868_20;
const animatedStyle4 = useAnimatedStyle(I);
const r91 = function() {
pressed.get();
return {
pointerEvents: "none"
};
};
r91.__closure = {
pressed
};
r91.__workletHash = 3473531476662;
r91.__initData = c10868_21;
const animatedProps = useAnimatedProps(r91);
const props2 = {
text: intl.string(t.zf5jU5),
variant: "primary",
size: null,
onPress: null
};
let size = "md";
props2.size = compactMode ? "sm" : "md";
props2.onPress = onAccept;
const r145 = [<ReanimatedRexport.View style={[styles.actionButtonsContainer, animatedStyle]}>
<Stack direction="horizontal" spacing={8}>
<View onLayout={function onLayout(event) {
sharedValue.set(event.nativeEvent.layout.width);
}}>
<Button key="accept_friend_request" {...props2} />
</View>
<Button key="ignore_friend_request" text={intl.string(t.EBN847)} variant="secondary" size={compactMode ? "sm" : "md"} onPress={onIgnore} />
</Stack>
</ReanimatedRexport.View>, ,];
const props3 = {
style: animatedStyle2,
onLayout: function onLayout(a0) {
sharedValue2.set(a0.nativeEvent.layout.width);
},
...animatedProps
};
const props4 = {
variant: "secondary",
text: intl.string(t.n8nU4W),
icon: <ReanimatedRexport.View style={animatedStyle3} accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
<ReanimatedRexport.View style={animatedStyle4} onLayout={function onLayout(event) {
sharedValue3.set(event.nativeEvent.layout.width);
sharedValue4.set(event.nativeEvent.layout.height);
}}>
<Text maxFontSizeMultiplier={2} variant="text-sm/normal">👋</Text>
</ReanimatedRexport.View>
</ReanimatedRexport.View>,
size: null,
onPress: null
};
if (compactMode) {
size = "sm";
}
props4.size = size;
props4.onPress = onWavePress;
props3.children = <Button {...props4} />;
r145[1] = <ReanimatedRexport.View {...props3} />;
return <View>{r145}</View>;
};
useStyles = createStyles({
buttonsContainer: {
flexDirection: "row",
marginTop: 8
},
actionButtonsContainer: {
flexDirection: "row",
position: "absolute",
left: 0
}
});
c10868_15 = {
ACCEPT: "accept",
IGNORE: "ignore",
WAVE: "wave",
ACTION: "action"
};
c10868_17 = {
code: "function ForYouItemActionButtonsTsx1(){const{withTiming,pressed}=this.__closure;return{opacity:withTiming(!pressed.get()?1:0,{duration:150}),pointerEvents:!pressed.get()?'auto':'none'};}"
};
c10868_18 = {
code: "function ForYouItemActionButtonsTsx2(){const{pressed,acceptButtonWidth,buttonWidth,withTiming}=this.__closure;const scaleX=!pressed.get()?acceptButtonWidth.get()/buttonWidth.get():1;const scaledWidth=buttonWidth.get()-buttonWidth.get()*scaleX;const translateX=!pressed.get()?-scaledWidth/2:0;return{transform:[{scaleX:withTiming(scaleX)},{translateX:withTiming(translateX)}],opacity:withTiming(!pressed.get()?0:1),pointerEvents:!pressed.get()?'none':'auto'};}"
};
c10868_19 = {
code: "function ForYouItemActionButtonsTsx3(){const{waveWidth,waveHeight}=this.__closure;return{transform:[{translateX:waveWidth.get()/2},{translateY:waveHeight.get()/2}]};}"
};
c10868_20 = {
code: "function ForYouItemActionButtonsTsx4(){const{withDelay,withRepeat,withTiming,pressed,Easing,waveWidth,waveHeight}=this.__closure;return{transform:[{rotateZ:withDelay(450,withRepeat(withTiming(pressed.get()?'8deg':'-2deg',{duration:150,easing:Easing.inOut(Easing.quad)}),4,true))},{translateX:-waveWidth.get()/2},{translateY:-waveHeight.get()/2}]};}"
};
c10868_21 = {
code: "function ForYouItemActionButtonsTsx5(){const{pressed}=this.__closure;return{pointerEvents:!pressed.get()?'none':'none'};}"
};
export { IncomingFriendRequestActions };
export function useItemActionButtonPropsV2(a0, a1, a2, a3, a4, a5, a6, a7) {
let r166, accessibilityActions, id2, text;
let callback, sharedValue5, callback2, callback3;
let c21854_0 = a0;
let r3 = a0.other_user?.id;
if (r3 == null) {
r3 = EMPTY_STRING_SNOWFLAKE_ID;
}
const userId = r3;
const location2 = "notification_center_v2";
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(c21854_0.message?.channel_id));
const canReplyToMessage2 = useCanReplyToMessage(stateFromStores, a0.message);
const type = a0.message?.type;
const POLL_RESULT = MessageTypes.POLL_RESULT;
callback = useCallback(() => {
sendWave(userId, false, "You Tab");
const dMFromUserId = ChannelStore.getDMFromUserId(userId);
if (dMFromUserId != null) {
handleSupportedURL({
payload: parseURL(`https://discord.com/channels/@me/${dMFromUserId}`).payload,
safe: true,
navigationReplace: false
});
}
a5(c21854_0);
}, [userId, a5, a0]);
sharedValue5 = useSharedValue(false);
callback2 = useCallback(() => {
PeopleUtils.maybeConfirmFriendRequestAccept({
userId,
applicationId: c21854_0.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS ? c21854_0.applicationId : void 0,
location: location2,
onConfirm: () => {
const user = UserStore.getUser(userId);
if (user != null) {
const r20 = t["5Uzkdp"];
let globalName = user.globalName;
if (globalName == null) {
globalName = user.username;
}
a6(intl.formatToPlainString(r20, {
username: `**${globalName}**`
}));
}
sharedValue5.set(true);
c21854_0.enableBadge = false;
a3(c21854_0);
}
});
}, [a3, sharedValue5, a0, userId, a6]);
callback3 = useCallback(() => {
PeopleUtils.cancelFriendRequest({
userId,
applicationId: c21854_0.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS ? c21854_0.applicationId : void 0,
location: location2
});
}, [a0.applicationId, a0.type, userId]);
const callback4 = useCallback(() => {
if (a2 != null) {
a2.navigate("friends", {
screen: "requests"
});
}
}, [a2]);
const callback5 = useCallback(() => {
ChannelActionCreators.getDMChannel(userId).then((result) => {
let env30863;
handleSupportedURL({
payload: parseURL(`https://discord.com/channels/@me/${result}`).payload,
safe: true,
navigationReplace: false
});
const r20 = env30863 = {
$parent: env10868
};
env30863[0] = void 0;
env30863[0] = result != null ? {
channelId: result
} : void 0;
setTimeout($mk96007(r20), 0);
});
}, [userId]);
const callback6 = useCallback(() => {
RelationshipActionCreators.addRelationship({
userId,
context: {
location: location2
}
});
ToastActionCreators.open({
key: "NOTIF_CENTER_V2_ADD_FRIEND_TOAST",
content: intl.string(t["7MAxkR"])
});
}, [userId]);
const callback7 = useCallback(async () => {
let c27988_0;
L14: {
c27988_0 = void 0;
if (c21854_0.message_id != null && stateFromStores != null) {
await createShallowPendingReply({
messageId: c21854_0.message_id,
channel: stateFromStores,
shouldMention: true,
showMentionToggle: true
});
(0, a1)();
(0, focusChatInput)(c21854_0.message_channel_id);
break L14;
}
(0, a1)();
(0, focusChatInput)(c21854_0.message_channel_id);
return void 0;
}
}, [a1, stateFromStores, a0.message_id, a0.message_channel_id]);
const callback8 = useCallback(() => {
let env27989;
a1();
const message_channel_id = c21854_0.message_channel_id;
const r10 = env27989 = {
$parent: env10868
};
env27989[0] = void 0;
env27989[0] = message_channel_id != null ? {
channelId: message_channel_id
} : void 0;
setTimeout($mk96007(r10), 0);
}, [a1, a0.message_channel_id]);
if (a0.disable_action) {
return {
actionButtons: []
};
}
L52: {
if (a0.type !== NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS) {
if (a0.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED && a4(a0)) {
break L52;
}
if (a0.type !== NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS) {
if (a0.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED && a4(a0)) {
break L52;
}
if (a0.type === NotificationCenterLocalItems.FRIEND_REQUESTS_GROUPED) {
return {
actionButtons: [{
id: "view_friend_requests",
text: intl.string(t["lMR96+"]),
variant: "secondary",
size: "md",
onPress: callback4
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["lMR96+"])
}],
onAccessibilityAction: callback4
};
}
if (a0.type === NotificationCenterItems.GO_LIVE_PUSH) {
return {
actionButtons: [{
id: "join_stream",
text: intl.string(t["Pqj7h+"]),
variant: "secondary",
size: "md",
onPress: a1
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["Pqj7h+"])
}],
onAccessibilityAction: a1
};
}
if (a0.type !== NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED && a0.type !== NotificationCenterItems.DM_FRIEND_NUDGE && a0.type !== NotificationCenterItems.FRIEND_REQUEST_ACCEPTED && a0.type !== NotificationCenterItems.GAME_FRIEND_REQUEST_ACCEPTED) {
if (a0.type === NotificationCenterItems.FRIEND_SUGGESTION_CREATED) {
return {
actionButtons: [{
id: "add_friend",
text: intl.string(t["boL/YX"]),
variant: "secondary",
size: "md",
onPress: callback6
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["boL/YX"])
}],
onAccessibilityAction: callback6
};
}
if (a0.type === NotificationCenterItems.GUILD_SCHEDULED_EVENT_STARTED) {
return {
actionButtons: [{
id: "join_event",
text: intl.string(t.hRKdcn),
variant: "secondary",
size: "md",
onPress: a1
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t.hRKdcn)
}],
onAccessibilityAction: a1
};
}
if (a0.type === NotificationCenterItems.LIFECYCLE_ITEM) {
const item_enum = a0.item_enum;
if (ItemEnum.UPDATE_PROFILE === item_enum) {
text = intl.string(t.zMRcWL);
id2 = "update_profile";
} else if (ItemEnum.FIND_FRIENDS === item_enum) {
text = intl.string(t["vwL/4s"]);
id2 = "find_friends";
} else if (ItemEnum.ADD_FRIEND === item_enum) {
text = intl.string(t["boL/YX"]);
id2 = "add_friend";
} else {
const FIRST_MESSAGE = ItemEnum.FIRST_MESSAGE;
id2 = null;
text = null;
if (FIRST_MESSAGE === item_enum) {
text = intl.string(t["GuUH7/"]);
id2 = "send_message";
}
}
return text != null && id2 != null ? {
actionButtons: [{
id: id2,
text,
variant: "secondary",
size: "md",
onPress: a1
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: text
}],
onAccessibilityAction: a1
} : {
actionButtons: []
};
}
L33: {
if (a0.type !== NotificationCenterItems.RECENT_MENTION && a0.type !== NotificationCenterItems.REPLY_MENTION) {
if (a0.type === NotificationCenterItems.TRENDING_CONTENT) {
r166 = {
actionButtons: [{
id: "read_summary",
text: intl.string(t.k0Q31F),
variant: "secondary",
size: "md",
onPress: callback8
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t.k0Q31F)
}],
onAccessibilityAction: callback8
};
break L33;
}
r166 = {
actionButtons: []
};
} else {
r166 = canReplyToMessage2 && type !== POLL_RESULT ? {
actionButtons: [{
id: "send_reply",
text: intl.string(t.vBq3iT),
variant: "secondary",
size: "md",
onPress: callback7
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t.vBq3iT)
}],
onAccessibilityAction: callback7
} : {
actionButtons: []
};
}
}
return r166;
}
return {
actionButtons: [{
id: "send_message",
text: intl.string(t["GuUH7/"]),
variant: "secondary",
size: "md",
onPress: callback5
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["GuUH7/"])
}],
onAccessibilityAction: callback5
};
}
}
}
const r406 = {
actionsNode: (0, jsx)(IncomingFriendRequestActions, {
onWavePress: callback,
onAccept: callback2,
onIgnore: callback3,
pressed: sharedValue5,
compactMode: a7
}),
accessibilityActions: null,
onAccessibilityAction: null
};
if (a0.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED) {
accessibilityActions = [{
name: c10868_15.WAVE,
label: intl.string(t.n8nU4W)
}];
} else {
accessibilityActions = [{
name: c10868_15.ACCEPT,
label: intl.string(t.zf5jU5)
}, {
name: c10868_15.IGNORE,
label: intl.string(t.EBN847)
}];
}
r406.accessibilityActions = accessibilityActions;
r406.onAccessibilityAction = (a0) => {
const actionName = a0.nativeEvent.actionName;
if (c10868_15.WAVE === actionName) {
callback();
} else if (c10868_15.ACCEPT === actionName) {
callback2();
} else if (c10868_15.IGNORE === actionName) {
callback3();
}
};
return r406;
}
export function ForYouItemActionButtons(props) {
let r20;
const { item, rowIndex, onSoftAckItem, actionButtons, actionsNode, compactMode, ...props2 } = props;
const styles = useStyles();
let r19 = compactMode ? !compactMode : actionButtons != null;
L9: {
const r1 = actionsNode != null;
if (!r19) {
r20 = null;
if (!r1) {
break L9;
}
}
if (r19) {
r19 = actionButtons.map((actionButton, index) => {
const { id: _id, ...rest } = actionButton;
let id2 = actionButton.id;
const id = id2;
let c27990_1 = rest;
const props = {
...rest,
onPress: (a0) => {
const onPress2 = c27990_1.onPress;
if (onPress2 != null) {
onPress2.call(c27990_1, a0);
}
onSoftAckItem(item);
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_CENTER_ACTION, {
action_type: NotificationCenterActionTypes.ACTION_BUTTON,
notification_center_id: item.id,
item_type: item.type,
acked: false,
item_index: rowIndex,
deeplink: item.deeplink,
action_button_id: id
});
}
};
if (id == null) {
id2 = index;
}
return <Button key={id2} {...props} />;
});
}
r20 = <View style={styles.buttonsContainer} {...props2}>
{r19}
{r1 ? actionsNode : null}
</View>;
}
return r20;
}
@@ -0,0 +1,206 @@
// Metro module 15295 (f15296).
import * as Module19 from "react";
import { useMemo } from "react";
import { View } from "react-native";
import { getGuildAcronym } from "../../../records/GuildRecord";
import GuildStore from "../../../stores/GuildStore";
import UserStore from "../../../stores/UserStore";
import * as _Constants from "../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { ItemEnum, NotificationCenterItems } from "../NotificationCenterItemsTypes";
import Module12259 from "../../../_bundle/Module12259";
import Module15297 from "../../../_bundle/Module15297";
import Module15298 from "../../../_bundle/Module15298";
import Module15299 from "../../../_bundle/Module15299";
import Module15300 from "../../../_bundle/Module15300";
import FastImage from "../../../components_native/common/FastImage";
import Module15301 from "../../../_bundle/Module15301";
import { Avatar, AvatarSizes, Icon, IconSizes } from "../../../design/void/native";
import Module15302 from "../../../_bundle/Module15302";
import Module15303 from "../../../_bundle/Module15303";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import { useStateFromStores } from "../../../_bundle/Module589";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import showUserProfileActionSheet from "../../user_profile/native/showUserProfileActionSheet";
import { getAvatarSource } from "../../profile_customization/native/ProfileCustomizationUtils";
import Module15304 from "../../../_bundle/Module15304";
import { Text } from "../../../design/components/Text/native/Text";
let useStyles2;
const { FRIEND_BACKGROUND, MESSAGE_BACKGROUND, PROFILE_BACKGROUND } = _Constants;
const useStyles = createStyles((a0) => {
const height = a0 ? 32 : 48;
const borderRadius = height / 2;
return {
container: {
height,
width: height,
borderRadius,
marginEnd: a0 ? 8 : 12,
alignItems: "center",
justifyContent: "center"
},
rowImage: {
height,
width: height,
borderRadius
},
guildFallbackImage: {
height: "auto",
maxHeight: borderRadius,
width: "auto",
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
}
};
});
useStyles2 = createStyles({
fallbackImage: {
color: Module712.colors.WHITE
},
fallbackImageV2: {
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
},
brandBackground: {
backgroundColor: Module712.colors.BACKGROUND_BRAND
},
profileBackground: {
backgroundColor: PROFILE_BACKGROUND
},
friendBackground: {
backgroundColor: FRIEND_BACKGROUND
},
messageBackground: {
backgroundColor: MESSAGE_BACKGROUND
},
guildGridBackground: {
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH
}
});
const r68 = Module19.memo(function({ item, compactMode }) {
let r45, r86, r161, brandBackground, profileBackground;
const styles = useStyles(compactMode);
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const styles2 = useStyles2();
const id = item.other_user?.id;
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getUser(id));
const memo = useMemo(() => stateFromStores != null ? <PressableOpacity onPress={() => {
showUserProfileActionSheet({
userId: stateFromStores.id,
localUser: stateFromStores,
messageId: item.message_id,
sourceAnalyticsLocations: analyticsLocations
});
}}>
<Avatar source={getAvatarSource(stateFromStores, item.guild_id, void 0, item.acked)} size={compactMode ? AvatarSizes.REFRESH_MEDIUM_32 : AvatarSizes.LARGE_48} avatarDecoration={stateFromStores.avatarDecoration} />
</PressableOpacity> : null, [stateFromStores, compactMode, item.acked, item.guild_id, item.message_id, analyticsLocations]);
if (item.icon_name != null) {
r45 = <Icon source={item.icon_name === "icHighlight" ? Module15299 : Module15300} color={styles2.fallbackImage.color} />;
brandBackground = styles2.brandBackground;
} else if (item.icon_url != null) {
const r208 = memo != null;
brandBackground = null;
r45 = memo;
if (!r208) {
r45 = <FastImage style={styles.rowImage} source={{
uri: item.icon_url
}} resizeMode="contain" />;
brandBackground = styles2.brandBackground;
}
} else {
const r43 = memo != null;
brandBackground = null;
r45 = memo;
if (!r43) {
if (item.type === "lifecycle_item") {
L40: {
const item_enum = item.item_enum;
if (item_enum === ItemEnum.UPDATE_PROFILE) {
r161 = <FastImage source={Module15301} />;
} else {
if (item_enum !== ItemEnum.FIND_FRIENDS && item_enum !== ItemEnum.ADD_FRIEND) {
if (item_enum === ItemEnum.FIRST_MESSAGE) {
r161 = <FastImage source={Module15303} style={{
width: "105%"
}} />;
break L40;
}
r161 = <Icon source={Module15300} />;
break L40;
}
r161 = <Icon source={Module15302} size={IconSizes.SMALL_20} color={Module712.unsafe_rawColors.WHITE} />;
}
}
L50: {
const item_enum2 = item.item_enum;
if (item_enum2 === ItemEnum.UPDATE_PROFILE) {
profileBackground = styles2.profileBackground;
} else {
if (item_enum2 !== ItemEnum.FIND_FRIENDS && item_enum2 !== ItemEnum.ADD_FRIEND) {
if (item_enum2 === ItemEnum.FIRST_MESSAGE) {
profileBackground = styles2.messageBackground;
break L50;
}
profileBackground = styles2.brandBackground;
break L50;
}
profileBackground = styles2.friendBackground;
}
}
if (profileBackground == null) {
profileBackground = null;
}
brandBackground = profileBackground;
r45 = r161;
} else if (item.type === NotificationCenterItems.REFERRAL_PROGRAM_ENTRYPOINT_REMINDER) {
r45 = <FastImage source={Module15304} style={styles.rowImage} resizeMode="contain" />;
brandBackground = styles2.brandBackground;
} else {
const guild = GuildStore.getGuild(item.guild_id);
const r19 = guild != null ? getGuildAcronym(guild) : null;
L20: {
const type = item.type;
if (NotificationCenterItems.MISSED_MESSAGES === type) {
r86 = {
icon: Module12259,
color: styles2.fallbackImage.color
};
} else if (NotificationCenterItems.FRIEND_REQUEST_REMINDER === type) {
r86 = {
icon: Module15297,
color: styles2.fallbackImage.color
};
} else {
if (NotificationCenterItems.GUILD_SCHEDULED_EVENT_STARTED !== type && NotificationCenterItems.TOP_MESSAGES !== type && NotificationCenterItems.MISSED_MESSAGES !== type) {
if (NotificationCenterItems.TOP_MESSAGES === type) {
r86 = {
icon: Module15299,
color: styles2.fallbackImage.color
};
break L20;
}
r86 = {
icon: Module15300,
color: styles2.fallbackImage.color
};
break L20;
}
r86 = {
icon: Module15298,
color: styles2.fallbackImageV2.color,
backgroundStyle: styles2.guildGridBackground
};
}
}
const r119 = r86.icon === Module15298 && r19 != null ? <Text variant={r19.length > 4 ? "text-md/normal" : "text-lg/normal"} style={[styles.rowImage, styles.guildFallbackImage]}>{r19}</Text> : <Icon source={r86.icon} color={r86.color} />;
let backgroundStyle = r86.backgroundStyle;
if (backgroundStyle == null) {
backgroundStyle = styles2.brandBackground;
}
brandBackground = backgroundStyle;
r45 = r119;
}
}
}
return <View style={[styles.container, brandBackground]}>{r45}</View>;
});
export { r68 as ForYouItemImage };
@@ -0,0 +1,636 @@
// 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 };
@@ -0,0 +1,24 @@
// Metro module 15317 (f15318).
import { ActivityIndicator, View } from "react-native";
import NotificationCenterItemsStore from "../NotificationCenterItemsStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import { Button } from "../../../design/components/Button/native/Button.native";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
container: {
alignItems: "center",
flexDirection: "row",
justifyContent: "center",
marginTop: 8,
marginBottom: 24,
marginHorizontal: 16,
height: 42
}
});
export function ForYouLoadMore(props) {
const onPressLoad = props.onPressLoad;
return <View style={useStyles().container}>
{useStateFromStores([NotificationCenterItemsStore], () => NotificationCenterItemsStore.loading) ? <ActivityIndicator /> : <Button variant="secondary" grow size="md" text={intl.string(t["Q/LSXp"])} onPress={onPressLoad} />}
</View>;
}
@@ -0,0 +1,77 @@
// Metro module 15287 (f15288).
import { View } from "react-native";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useStateFromStores } from "../../../_bundle/Module589";
import ReanimatedRexport, { useSharedValue, withRepeat, Easing, useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
import { withTiming } from "../../../design/animation/reanimated/timing/timing";
const useStyles = createStyles({
placeholder: {
flexDirection: "row",
marginBottom: 16,
marginHorizontal: 24
},
placeholderImage: {
backgroundColor: Module712.colors.BACKGROUND_MOD_STRONG,
height: 52,
width: 52,
borderRadius: 26,
marginEnd: 12
},
placeholderText: {
backgroundColor: Module712.colors.BACKGROUND_MOD_STRONG,
height: 15,
borderRadius: Module712.radii.sm,
marginRight: 12,
marginBottom: 4
},
placeholderTextContainer: {
flexDirection: "row",
flexWrap: "wrap"
},
placeholderBody: {
backgroundColor: Module712.colors.BACKGROUND_MOD_STRONG,
height: 40,
borderRadius: Module712.radii.sm,
marginTop: 4
}
});
let c10864_8 = [70, 50];
const __initData = {
code: "function ForYouMentionPlaceholderTsx1(){const{reducedMotion,opacity}=this.__closure;return{opacity:reducedMotion?0.7:opacity.get()};}"
};
export function ForYouMentionPlaceholder() {
let sharedValue;
const styles = useStyles();
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
sharedValue = useSharedValue(0.3);
sharedValue.set(withRepeat(withTiming(0.7, {
duration: 1000,
easing: Easing.inOut(Easing.ease)
}), -1, true));
const y = function y() {
return {
opacity: stateFromStores ? 0.7 : sharedValue.get()
};
};
y.__closure = {
reducedMotion: stateFromStores,
opacity: sharedValue
};
y.__workletHash = 8828208724188;
y.__initData = __initData;
return <ReanimatedRexport.View style={[styles.placeholder, useAnimatedStyle(y)]}>
<View style={styles.placeholderImage} />
<View>
<View style={styles.placeholderTextContainer}>
{c10864_8.map((item, index) => <View key={index} style={[styles.placeholderText, {
width: `${item}%`
}]} />)}
</View>
<View style={[styles.placeholderBody, {
width: "85%"
}]} />
</View>
</ReanimatedRexport.View>;
}
@@ -0,0 +1,26 @@
// Metro module 15305 (f15306).
import { View, StyleSheet } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
container: {
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: Module712.colors.BORDER_SUBTLE,
marginVertical: 8,
paddingHorizontal: 24
},
textHeader: {
color: Module712.colors.TEXT_SUBTLE,
marginTop: 20
}
});
export function ForYouReadSectionHeader() {
const styles = useStyles();
return <View style={styles.container}>
<Text style={styles.textHeader} variant="text-sm/semibold">
{intl.string(t.hftC1K)}
</Text>
</View>;
}
@@ -0,0 +1,24 @@
// Metro module 15306 (f15307).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
container: {
marginTop: Module712.space.PX_8,
marginBottom: Module712.space.PX_8,
paddingHorizontal: Module712.space.PX_24
},
textHeader: {
marginTop: Module712.space.PX_8
}
});
export function ForYouRecentActivitySectionHeader() {
const styles = useStyles();
return <View style={styles.container}>
<Text style={styles.textHeader} color="text-muted" variant="text-sm/semibold" accessibilityRole="header">
{intl.string(t.yM9Krm)}
</Text>
</View>;
}
@@ -0,0 +1,116 @@
// Metro module 15315 (f15316).
import { useCallback, useMemo } from "react";
import { View } from "react-native";
import { AnalyticEvents } from "../../../Constants";
import { Sections } from "../../main_tabs_v2/native/friends/screens/FriendsScreenConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { useMessagesTabLayout, getLayoutStyles, isLayoutCompact, makeSizeStyle } from "../../main_tabs_v2/native/shared_components/guild_channels/layouts/ChannelListLayout";
import Module712 from "../../../_bundle/Module712";
import { isAndroid } from "../../../utils/PlatformUtils";
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { AvatarSizes, Icon, IconSizes, Avatar } from "../../../design/void/native";
import { useFontScale } from "../../screen/native/useFontScale";
import { renderChannelPressableWrapper } from "../../main_tabs_v2/native/shared_components/guild_channels/ChannelPressableWrapper";
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
import { renderChannelWrapper } from "../../main_tabs_v2/native/shared_components/guild_channels/ChannelWrapper";
import { AvatarDuoPile } from "../../../design/components/Pile/native/AvatarDuoPile.native";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import Module5229 from "../../../_bundle/Module5229";
let useStyles;
const ForYouShowAllRow = function ForYouShowAllRow(props) {
const { children, count, onPress, panelVariant = false } = props;
const messagesTabLayout2 = useMessagesTabLayout(panelVariant);
const styles = useStyles(messagesTabLayout2);
const styles2 = getLayoutStyles(messagesTabLayout2);
const fontScale = useFontScale();
return renderChannelPressableWrapper(<PressableHighlight accessibilityRole="button" underlayColor={styles.rowActive.backgroundColor} onPress={onPress} style={[styles.pressable, {
borderRadius: styles2.container.borderRadius
}]}>
{renderChannelWrapper(<>
<View style={styles.avatar}>
<AvatarDuoPile size={isLayoutCompact(messagesTabLayout2) ? AvatarSizes.XSMALL_20 : AvatarSizes.SMALL} aria-label="">{children}</AvatarDuoPile>
</View>
<View style={styles.textContainer}>
<Text lineClamp={1} variant={styles2.channelName.text.variant} color="text-brand" style={styles.nameText}>
{intl.format(t.NrzztX, {
count
})}
</Text>
</View>
<Icon style={styles.icon} color={styles.iconColor.color} source={Module5229} size={IconSizes.CUSTOM} />
</>, {
layout: messagesTabLayout2,
fontScale,
panelVariant
})}
</PressableHighlight>, {
layout: messagesTabLayout2,
panelVariant
});
};
useStyles = createStyles((a0) => {
const styles = getLayoutStyles(a0);
const r20 = makeSizeStyle(styles.icon.wrapper.size);
return {
rowActive: {
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED
},
pressable: {
flex: 1
},
textContainer: {
flexDirection: "column",
flexGrow: 2,
flexShrink: 2,
alignSelf: "center",
overflow: "hidden",
marginTop: -2,
marginRight: Module712.space.PX_8
},
nameText: {
flexShrink: 1,
marginBottom: isAndroid() ? 2 : 0
},
avatar: {
position: "relative",
borderRadius: Module712.radii.round,
justifyContent: "center",
alignItems: "center",
flexShrink: 0,
flexGrow: 0,
...r20,
marginRight: styles.icon.margin.marginRight + 4
},
icon: {
width: 8,
height: 32,
paddingRight: Module712.space.PX_24
},
iconColor: {
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
}
};
});
export function ForYouSuggestedFriendShowAllRow(props) {
const { suggestedFriends, panelVariant = false } = props;
const navigation = useNavigation();
const messagesTabLayout = useMessagesTabLayout(panelVariant);
return <ForYouShowAllRow count={suggestedFriends.length} onPress={useCallback(() => {
AnalyticsUtils.track(AnalyticEvents.FRIEND_FINDER_SECTION_EXPANDED, {
section_id: Sections.FRIEND_SUGGESTIONS,
truncated_count: 2,
expanded_count: suggestedFriends.length,
location: "NotificationsTab"
});
navigation.navigate("friends", {
screen: "suggested-friends",
params: {
presentation: "card"
}
});
}, [navigation, suggestedFriends])} panelVariant={panelVariant}>
{useMemo(() => suggestedFriends.slice(2, 4).map((item) => <Avatar key={item.user.id} user={item.user} guildId={void 0} size={isLayoutCompact(messagesTabLayout) ? AvatarSizes.XSMALL_20 : AvatarSizes.SMALL} />), [messagesTabLayout, suggestedFriends])}
</ForYouShowAllRow>;
}
@@ -0,0 +1,126 @@
// Metro module 15309 (f15310).
import { useCallback, useEffect } from "react";
import { View } from "react-native";
import AccessibilityStore from "../../a11y/AccessibilityStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import { AnalyticEvents, RelationshipTypes } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { getLayoutStyles, makeSizeStyle, useMessagesTabLayout, isLayoutCozy } from "../../main_tabs_v2/native/shared_components/guild_channels/layouts/ChannelListLayout";
import Module712 from "../../../_bundle/Module712";
import { isAndroid } from "../../../utils/PlatformUtils";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import { useFontScale } from "../../screen/native/useFontScale";
import { useStateFromStoresObject, useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import UserUtils from "../../../utils/UserUtils";
import { getSuggestedContactNameForSuggestion } from "../../friend_suggestions/FriendSuggestionUtils";
import { intl, t } from "../../../intl/index.native";
import { useSharedValue } from "../../reanimated/ReanimatedRexport";
import { renderChannelPressableWrapper } from "../../main_tabs_v2/native/shared_components/guild_channels/ChannelPressableWrapper";
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
import { renderChannelWrapper } from "../../main_tabs_v2/native/shared_components/guild_channels/ChannelWrapper";
import { Avatar } from "../../../design/void/native";
import { Text } from "../../../design/components/Text/native/Text";
import { ActionStatusSubLabel } from "../../main_tabs_v2/native/friends/components/ActionStatusSubLabel";
import { ContactSuggestionActions } from "../../main_tabs_v2/native/friends/components/ContactSuggestionActions";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
const useStyles = createStyles((a0) => {
const styles = getLayoutStyles(a0);
const r20 = makeSizeStyle(styles.icon.wrapper.size);
return {
rowActive: {
backgroundColor: Module712.colors.BACKGROUND_MOD_MUTED
},
pressable: {
flex: 1
},
textContainer: {
flexDirection: "column",
flexGrow: 2,
flexShrink: 2,
alignSelf: "center",
overflow: "hidden",
marginTop: -2,
marginRight: Module712.space.PX_8
},
nameText: {
flexShrink: 1,
marginBottom: isAndroid() ? 2 : 0
},
avatar: {
position: "relative",
borderRadius: Module712.radii.round,
justifyContent: "center",
alignItems: "center",
flexShrink: 0,
flexGrow: 0,
...r20,
marginRight: styles.icon.margin.marginRight + 4
}
};
});
export default function ForYouSuggestedFriendRow(props) {
let sharedValue, stateFromStores;
const { suggestedFriend, onAddSuggestion: onAddSuggestion2, onAddSuggestionAnimationFinish, panelVariant = false } = props;
sharedValue = void 0;
stateFromStores = void 0;
const messagesTabLayout = useMessagesTabLayout(panelVariant);
const styles = useStyles(messagesTabLayout);
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const styles2 = getLayoutStyles(messagesTabLayout);
const fontScale = useFontScale();
const stateFromStoresObject = useStateFromStoresObject([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
const callback = useCallback(() => {
import("../../user_profile/native/showUserProfileActionSheet").then((result) => (0, result.default)({
userId: suggestedFriend.user.id,
localUser: suggestedFriend.user,
sourceAnalyticsLocations: analyticsLocations,
location: "Notifications Tab User Profile"
}));
}, [suggestedFriend, analyticsLocations]);
const friendSuggestionName = suggestedFriend.friendSuggestionName;
const r68 = friendSuggestionName != null && suggestedFriend.friendSuggestionName.length > 0 ? suggestedFriend.friendSuggestionName : UserUtils.getName(suggestedFriend.user);
const suggestedContactNameForSuggestion = getSuggestedContactNameForSuggestion(r68, suggestedFriend);
const r5 = suggestedContactNameForSuggestion != null;
const r33 = r5 ? ` · ${suggestedContactNameForSuggestion}` : "";
const r32 = suggestedFriend.mutualFriendsCount != null && suggestedFriend.mutualFriendsCount > 0 ? intl.formatToPlainString(t.z7y34b, {
count: suggestedFriend.mutualFriendsCount
}) : UserUtils.getName(suggestedFriend.user);
sharedValue = useSharedValue(false);
stateFromStores = useStateFromStores([RelationshipStore], () => RelationshipStore.getRelationshipType(suggestedFriend.user.id) === RelationshipTypes.PENDING_OUTGOING);
useEffect(() => {
if (!stateFromStores) {
sharedValue.set(false);
}
}, [sharedValue, stateFromStores]);
const r135 = [<View style={styles.avatar}>
<Avatar user={suggestedFriend.user} guildId={void 0} size={styles2.icon.avatarSize} animate={!stateFromStoresObject} />
</View>, <View style={styles.textContainer}>
<Text lineClamp={1} variant={styles2.channelName.text.variant} color="text-default" style={styles.nameText}>{r68}</Text>
<View style={{
marginTop: isAndroid() ? -2 : 0
}}>
<ActionStatusSubLabel lineHeight={styles2.messagePreview.height + (isAndroid() ? 2 : 0)} textVariant={styles2.messagePreview.text.variant} actioned={sharedValue} maxFontSizeMultiplier={1.75} label={`${r32}${r33}`} actionStatus={intl.string(t.Kzyxm9)} animate={!stateFromStoresObject} />
</View>
</View>, <ContactSuggestionActions user={suggestedFriend.user} added={sharedValue} size={isLayoutCozy(messagesTabLayout) ? "md" : "sm"} onAddSuggestion={(event) => {
AnalyticsUtils.track(AnalyticEvents.FRIEND_SUGGESTION_ADDED, {
suggested_user_id: event.id,
suggestion_source: suggestedFriend.source,
location: "Notifications Tab"
});
onAddSuggestion2(suggestedFriend);
}} onFinishAnimation={() => {
onAddSuggestionAnimationFinish(suggestedFriend);
}} animate={!stateFromStoresObject} />];
return renderChannelPressableWrapper(<PressableHighlight accessibilityRole="button" underlayColor={styles.rowActive.backgroundColor} onPress={callback} style={[styles.pressable, {
borderRadius: styles2.container.borderRadius
}]}>
{renderChannelWrapper(<>{r135}</>, {
layout: messagesTabLayout,
fontScale,
panelVariant
})}
</PressableHighlight>, {
layout: messagesTabLayout,
panelVariant
});
};
@@ -0,0 +1,34 @@
// Metro module 15308 (f15309).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
container: {
borderTopWidth: 1,
borderTopColor: Module712.colors.BORDER_SUBTLE,
marginTop: 12,
marginBottom: 8,
paddingHorizontal: 24,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between"
},
noDivider: {
borderTopWidth: 0,
marginTop: 0
},
text: {
marginTop: Module712.space.PX_16
}
});
export default function ForYouSuggestedFriendsSectionHeader(props) {
const showDivider = props.showDivider;
const styles = useStyles();
return <View style={[styles.container, showDivider ? !showDivider : styles.noDivider]}>
<Text style={styles.text} color="text-muted" variant="text-sm/semibold">
{intl.string(t["1uAmCw"])}
</Text>
</View>;
};
@@ -0,0 +1,49 @@
// Metro module 15316 (f15317).
import { View } from "react-native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Icon } from "../../../design/void/native";
import Module9690 from "../../../_bundle/Module9690";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
const useStyles = createStyles({
container: {
marginBottom: 4,
marginHorizontal: 24,
alignItems: "center",
flexDirection: "row"
},
imageContainer: {
width: 48,
height: 48,
backgroundColor: Module712.unsafe_rawColors.GREEN_400,
opacity: 0.16,
borderRadius: Module712.radii.xl,
marginRight: 16,
justifyContent: "center",
alignItems: "center"
},
icon: {
margin: 12,
position: "absolute",
color: Module712.unsafe_rawColors.GREEN_400
},
headerText: {
marginBottom: 2
}
});
export function ForYouUnreadClearedState() {
const styles = useStyles();
return <View style={styles.container}>
<View style={styles.imageContainer} />
<Icon source={Module9690} style={styles.icon} color={styles.icon.color} />
<View>
<Text color="mobile-text-heading-primary" variant="text-md/semibold" style={styles.headerText}>
{intl.string(t.DonStq)}
</Text>
<Text color="text-default" variant="text-md/medium">
{intl.string(t.jXFsai)}
</Text>
</View>
</View>;
}
@@ -0,0 +1,8 @@
// Metro module 15276 (f15277).
import { IconButton } from "../../../design/components/Button/native/IconButton.native";
import Module8964 from "../../../_bundle/Module8964";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { intl, t } from "../../../intl/index.native";
export default function NotificationCenterActionButton() {
return <IconButton variant="tertiary" size="sm" icon={Module8964} onPress={() => ActionSheetActionCreators.openLazy(import("./NotificationCenterActionSheet"), "NotificationCenterActionSheet")} accessibilityLabel={intl.string(t["UKOtz+"])} maxFontSizeMultiplier={2} />;
};
@@ -0,0 +1,75 @@
// Metro module 15277 (f15278).
import { useCallback } from "react";
import RecentMentionsStore from "../../inbox/RecentMentionsStore";
import { UserSettingsSections } from "../../../Constants";
import { useStateFromStoresObject } from "../../../_bundle/Module589";
import MentionActionCreators from "../../../actions/MentionActionCreators";
import ForLaterExperiment from "../../saved_messages/ForLaterExperiment";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import hasForLaterPremiumType from "../../saved_messages/hasForLaterPremiumType";
import openPremiumUpsellActionSheet from "../../premium/roadblocks/native/utils/openPremiumUpsellActionSheet";
import { EntitlementFeatureNames } from "../../../_bundle/Module6201";
import { showForLaterModal } from "../../saved_messages/native/showForLaterModal";
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
import { BottomSheetTitleHeader } from "../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
import { intl, t } from "../../../intl/index.native";
import { ActionSheetRow, ActionSheetSwitchRow } from "../../../design/components/Sheet/native/ActionSheetRow.native";
import { AtIcon } from "../../../design/components/Icon/native/redesign/generated/AtIcon";
import Module10390 from "../../../_bundle/Module10390";
import { BellIcon } from "../../../design/components/Icon/native/redesign/generated/BellIcon";
import Module15279 from "../../../_bundle/Module15279";
import { BookmarkIcon } from "../../../design/components/Icon/native/redesign/generated/BookmarkIcon";
import { SavedMessageSortTypes } from "../../saved_messages/SavedMessagesTypes";
import { ClockIcon } from "../../../design/components/Icon/native/redesign/generated/ClockIcon";
import { SettingsIcon } from "../../../design/components/Icon/native/redesign/generated/SettingsIcon";
export default function NotificationCenterActionSheet() {
let roleFilter, everyoneFilter, callback, callback2;
const stateFromStoresObject = useStateFromStoresObject([RecentMentionsStore], () => ({
everyoneFilter: RecentMentionsStore.everyoneFilter,
roleFilter: RecentMentionsStore.roleFilter
}));
roleFilter = stateFromStoresObject.roleFilter;
everyoneFilter = stateFromStoresObject.everyoneFilter;
callback = useCallback((a0) => {
MentionActionCreators.setGuildFilter({
roleFilter,
everyoneFilter,
...a0
});
}, [everyoneFilter, roleFilter]);
const enabled = ForLaterExperiment.useConfig({
location: "NotificationCenterActionSheet"
}).enabled;
callback2 = useCallback((a0) => {
ActionSheetActionCreators.hideActionSheet();
if (hasForLaterPremiumType()) {
showForLaterModal(a0);
} else {
openPremiumUpsellActionSheet(EntitlementFeatureNames.SAVED_MESSAGES);
}
}, []);
const callback3 = useCallback(() => {
ActionSheetActionCreators.hideActionSheet();
openUserSettings({
screen: UserSettingsSections.NOTIFICATIONS
});
}, []);
const props = {
showGradient: true,
header: <BottomSheetTitleHeader title={intl.string(t.HcoRu0)} />,
children: [<ActionSheetRow.Group hasIcons>
<ActionSheetSwitchRow onValueChange={() => callback({
roleFilter: !roleFilter
})} value={roleFilter} label={intl.string(t.asInft)} icon={<ActionSheetRow.Icon IconComponent={AtIcon} source={Module10390} />} />
<ActionSheetSwitchRow onValueChange={() => callback({
everyoneFilter: !everyoneFilter
})} value={everyoneFilter} label={intl.string(t.S9GLtt)} subLabel={intl.string(t.jYgZa4)} icon={<ActionSheetRow.Icon IconComponent={BellIcon} source={Module15279} />} />
</ActionSheetRow.Group>, <ActionSheetRow.Group hasIcons>
{enabled ? <ActionSheetRow key="bookmarks" icon={<ActionSheetRow.Icon IconComponent={BookmarkIcon} />} label={intl.string(t["2pAkDA"])} onPress={() => callback2(SavedMessageSortTypes.BOOKMARK)} arrow /> : null}
{enabled ? <ActionSheetRow key="reminders" icon={<ActionSheetRow.Icon IconComponent={ClockIcon} />} label={intl.string(t.aUXxzT)} onPress={() => callback2(SavedMessageSortTypes.REMINDER)} arrow /> : null}
<ActionSheetRow key="settings" icon={<ActionSheetRow.Icon IconComponent={SettingsIcon} />} label={intl.string(t.h850Ss)} onPress={callback3} arrow />
</ActionSheetRow.Group>]
};
return <ActionSheet {...props} />;
};
@@ -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>;
};
@@ -0,0 +1,104 @@
// Metro module 15280 (f15281).
import { useCallback, useEffect } from "react";
import { View } from "react-native";
import { AnalyticEvents, NOOP } from "../../../Constants";
import { ContentDismissActionType } from "../../dismissible_content/DismissibleContentConstants";
import { EventActionLocation, EventActionType, NotificationNudgeAnalyticsAction, NotificationNudgeSurface } from "../../nuf/native/components/notification/NotificationPermissionConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { BellSlashIcon } from "../../../design/components/Icon/native/redesign/generated/BellSlashIcon";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { Button } from "../../../design/components/Button/native/Button.native";
import { requestPushNotificationPermission, useCanSeePushNotificationNudge } from "../../nuf/native/NotificationPermissionUtil";
import { PressableHighlight } from "../../../design/void/Pressables/native/Pressables";
import { XSmallIcon } from "../../../design/components/Icon/native/redesign/generated/XSmallIcon";
import ContextualOptInNudgeHoldoutExperiment from "../../nuf/native/ContextualOptInNudgeHoldoutExperiment";
import { useSelectedTimeRecurringDismissibleContent } from "../../dismissible_content/hooks/useSelectedDismissibleContent";
import { DismissibleContent } from "../../../_bundle/Module1358";
let useStyles;
const NotificationCenterBannerImpl = function NotificationCenterBannerImpl(props) {
const onDismiss = props.onDismiss;
const styles = useStyles();
useEffect(() => {
AnalyticsUtils.track(AnalyticEvents.CONTEXTUAL_REMINDER_ACTION, {
action: NotificationNudgeAnalyticsAction.IMPRESSION,
prompt_type: NotificationNudgeSurface.NOTIFICATION_CENTER_BANNER
});
}, []);
return <View style={styles.container}>
<View style={styles.iconContainer}>
<BellSlashIcon size="md" color={Module712.colors.ICON_STRONG} />
</View>
<View style={styles.contentContainer}>
<Text variant="text-md/semibold" color="text-default">
{intl.string(t.G6YBna)}
</Text>
<Text variant="text-md/medium" color="text-muted" style={{
marginTop: Module712.space.PX_4
}}>
{intl.string(t["9CoPDE"])}
</Text>
<View style={styles.ctaButton}>
<Button variant="primary" size="md" text={intl.string(t.a4bgO0)} onPress={function onPress() {
requestPushNotificationPermission(EventActionType.ALLOW_TO_REQUEST, EventActionLocation.NOTIFICATION_CENTER, NOOP);
AnalyticsUtils.track(AnalyticEvents.CONTEXTUAL_REMINDER_ACTION, {
action: NotificationNudgeAnalyticsAction.ACCEPT,
prompt_type: NotificationNudgeSurface.NOTIFICATION_CENTER_BANNER
});
}} />
</View>
</View>
<PressableHighlight onPress={function onPress() {
AnalyticsUtils.track(AnalyticEvents.CONTEXTUAL_REMINDER_ACTION, {
action: NotificationNudgeAnalyticsAction.DISMISS,
prompt_type: NotificationNudgeSurface.NOTIFICATION_CENTER_BANNER
});
onDismiss();
}} hitSlop={8} accessibilityRole="button" accessibilityLabel={intl.string(t.WAI6xu)}>
<XSmallIcon size="sm" color="icon-strong" />
</PressableHighlight>
</View>;
};
useStyles = createStyles({
container: {
flexDirection: "row",
paddingLeft: 24,
paddingRight: Module712.space.PX_12,
paddingVertical: Module712.space.PX_16,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
alignItems: "flex-start",
borderBottomWidth: 1,
borderColor: Module712.colors.BORDER_SUBTLE,
gap: 16
},
contentContainer: {
flex: 1
},
iconContainer: {
width: 48,
height: 48,
borderRadius: Module712.radii.round,
backgroundColor: Module712.colors.BACKGROUND_MOD_STRONG,
alignItems: "center",
justifyContent: "center"
},
ctaButton: {
alignSelf: "flex-start",
marginTop: Module712.space.PX_12
}
});
export default function NotificationCenterPermissionNudge() {
const inHoldout = ContextualOptInNudgeHoldoutExperiment.useConfig({
location: "NotificationCenterPermissionNudge"
}).inHoldout;
const canSeePushNotificationNudge = useCanSeePushNotificationNudge();
const r8 = inHoldout ? null : canSeePushNotificationNudge ? DismissibleContent.NOTIFICATION_NUDGE_NOTIFICATION_CENTER_BANNER : null;
const [r28, r29] = useSelectedTimeRecurringDismissibleContent(r8, {
cooldownDurationMs: 604800000
});
let c21840_0 = r29;
const callback = useCallback(() => c21840_0(ContentDismissActionType.USER_DISMISS), [r29]);
return r28 === DismissibleContent.NOTIFICATION_NUDGE_NOTIFICATION_CENTER_BANNER ? <NotificationCenterBannerImpl onDismiss={callback} /> : null;
};
@@ -0,0 +1,20 @@
// Metro module 15285 (f15286).
import { useMemo } from "react";
import { NotificationCenterLocalItems } from "./NotificationCenterItemsTypes";
import useGetOrFetchApplications from "../applications/useGetOrFetchApplications";
let c10862_3 = new Set([NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS, NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED, NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS, NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED]);
export function useGetOrFetchNotificationCenterItemsApplications(a0) {
return useGetOrFetchApplications(useMemo(() => {
let c27986_0 = new Set();
const r10 = [];
let c27986_1 = r10;
a0.forEach((item) => {
const applicationId = item.applicationId;
if (c10862_3.has(item.type) && !(applicationId == null || c27986_0.has(applicationId))) {
c27986_0.add(applicationId);
c27986_1.push(applicationId);
}
});
return r10;
}, [a0]));
}
@@ -0,0 +1,16 @@
// Metro module 15289 (f15290).
import NotificationCenterStore from "./NotificationCenterStore";
import { useStateFromStores } from "../../_bundle/Module589";
import { isRemoteAcked } from "./NotificationCenterUtils";
export function useNotificationCenterItemAcked(a0, a1) {
let r12 = useStateFromStores([NotificationCenterStore], () => NotificationCenterStore.isLocalItemAcked(a0));
const forceUnacked = a0.forceUnacked;
let r14 = !forceUnacked;
if (!forceUnacked) {
if (!r12) {
r12 = isRemoteAcked(a0, a1);
}
r14 = r12;
}
return r14;
}
@@ -0,0 +1,166 @@
// Metro module 15283 (f15284).
import _slicedToArray from "../../_bundle/_slicedToArray";
import { useRef, useState, useEffect, useCallback } from "react";
import RecentMentionsStore from "../inbox/RecentMentionsStore";
import NotificationCenterItemsStore from "./NotificationCenterItemsStore";
import NotificationCenterStore from "./NotificationCenterStore";
import { ReadStateTypes } from "../read_states/ReadStateConstants";
import { useStateFromStores, useStateFromStoresObject } from "../../_bundle/Module589";
import { setNotificationCenterActive, resetNotificationCenter, fetchNotificationCenterItems } from "./NotificationCenterItemsActions";
import { ackUserFeature } from "../../actions/ReadStateActionCreators";
import useGetIsMounted from "../../hooks/useGetIsMounted";
let env10860 = {};
export const PAGE_SIZE_WITH_MENTIONS = 8;
export const PAGE_SIZE = 20;
export function useNotificationCenterItemsLoader(a0) {
let env21842 = {
$parent: env10860
};
const isFocused = a0.isFocused;
env21842[0] = isFocused;
const navigatedAway = a0.navigatedAway;
env21842[1] = navigatedAway;
const isDesktop = a0.isDesktop;
env21842[2] = isDesktop;
let withMentions = a0.withMentions;
if (withMentions === void 0) {
withMentions = false;
}
let c21843_0;
env21842[3] = withMentions;
const initialPageSize = a0.initialPageSize;
env21842[4] = initialPageSize;
env21842[5] = void 0;
env21842[6] = void 0;
env21842[7] = void 0;
env21842[8] = void 0;
env21842[9] = void 0;
env21842[10] = void 0;
env21842[11] = void 0;
env21842[12] = void 0;
env21842[13] = void 0;
env21842[14] = void 0;
env21842[15] = void 0;
const stateFromStores = useStateFromStores([NotificationCenterStore], () => NotificationCenterStore.shouldReload());
env21842[5] = stateFromStores;
env21842[6] = useRef(false);
const r33 = _slicedToArray(useState(false), 2);
const loadingMore = r33[0];
env21842[7] = r33[1];
const stateFromStoresObject = useStateFromStoresObject([NotificationCenterItemsStore], () => ({
initialized: NotificationCenterItemsStore.initialized,
loading: NotificationCenterItemsStore.loading,
items: NotificationCenterItemsStore.items,
hasMore: NotificationCenterItemsStore.hasMore,
cursor: NotificationCenterItemsStore.cursor,
errored: NotificationCenterItemsStore.errored
}));
const initialized = stateFromStoresObject.initialized;
env21842[8] = initialized;
const { loading, items } = stateFromStoresObject;
env21842[9] = items;
const hasMore = stateFromStoresObject.hasMore;
env21842[10] = hasMore;
const cursor = stateFromStoresObject.cursor;
env21842[11] = cursor;
const errored = stateFromStoresObject.errored;
env21842[12] = errored;
const stateFromStoresObject2 = useStateFromStoresObject([RecentMentionsStore], () => ({
everyoneFilter: RecentMentionsStore.everyoneFilter,
roleFilter: RecentMentionsStore.roleFilter
}));
const roleFilter = stateFromStoresObject2.roleFilter;
env21842[13] = roleFilter;
const everyoneFilter = stateFromStoresObject2.everyoneFilter;
env21842[14] = everyoneFilter;
useEffect(() => {
setNotificationCenterActive(true);
return () => setNotificationCenterActive(false);
}, []);
useEffect(() => {
if (env21842[8] && env21842[0]) {
ackUserFeature(ReadStateTypes.NOTIFICATION_CENTER);
}
}, [isFocused, initialized]);
const getIsMounted = useGetIsMounted();
env21842[15] = getIsMounted;
useEffect(() => () => {
if (env21842[2]) {
const r17 = (0, env21842[15])();
if (r17 ? !r17 : env21842[12] || env21842[9].length > 100) {
resetNotificationCenter();
}
} else if (env21842[1] && env21842[9].length > 100) {
resetNotificationCenter();
}
}, [navigatedAway, items, isDesktop, getIsMounted, errored]);
useEffect(() => {
const r4 = env21842[8];
if (r4 ? env21842[5] && env21842[0] : !r4) {
let limit = env21842[4];
if (limit == null) {
limit = env21842[3] ? 8 : 20;
}
fetchNotificationCenterItems({
limit,
with_mentions: env21842[3],
roles_filter: env21842[13],
everyone_filter: env21842[14]
});
}
}, [initialized, stateFromStores, isFocused, withMentions, roleFilter, everyoneFilter, initialPageSize]);
c21843_0 = void 0;
c21843_0 = async (c30857_0) => {
let r47;
let c30857_1;
L26: {
c30857_1 = void 0;
const r10 = env21842[6];
if (r10.current || !env21842[8] || !env21842[10] || env21842[11] == null || (c30857_0 ? !c30857_0 : env21842[12])) {
break L26;
}
r10.current = true;
(0, env21842[7])(true);
const after = env21842[11];
const with_mentions = env21842[3];
const r42 = {
after,
with_mentions,
roles_filter: env21842[13],
everyone_filter: env21842[14],
limit: null
};
const limit = 20;
if (!with_mentions) {
r42.limit = limit;
r47 = fetchNotificationCenterItems(r42, () => {
env21842[6].current = false;
});
} else {
r42.limit = 8;
r47 = fetchNotificationCenterItems(r42, () => {
env21842[6].current = false;
});
}
await r47;
(0, env21842[7])(false);
return void 0;
}
};
return {
initialized,
loading,
items,
hasMore,
loadMore: useCallback(function() {
return c21843_0.apply(this, arguments);
}, [initialized, hasMore, cursor, errored, withMentions, roleFilter, everyoneFilter]),
loadingMore,
setReadNotifItemToAcked: function setReadNotifItemToAcked(a0) {
if (!a0.acked) {
a0.acked = true;
}
},
errored
};
}
@@ -0,0 +1,24 @@
// Metro module 15033 (f15034).
import { useState, useEffect } from "react";
import { getRelativeTimestamp } from "./NotificationCenterUtils";
import Durations from "../../utils/Durations";
export function useRelativeTimestamp({ timestamp, abbreviated = true }) {
let setState;
let c21543_1 = abbreviated;
setState = void 0;
let state;
[state, setState] = useState(() => getRelativeTimestamp(timestamp, c21543_1));
useEffect(() => {
setState(getRelativeTimestamp(timestamp, c21543_1));
const r17 = Date.now() - timestamp;
if (r17 > Durations.Millis.DAY) {
return void 0;
}
const r30 = r17 >= Durations.Millis.HOUR ? Durations.Millis.HOUR : Durations.Millis.MINUTE;
let c27888_0 = setInterval(() => {
setState(getRelativeTimestamp(timestamp, c21543_1));
}, r30, r30 - r17 % r30);
return () => clearInterval(c27888_0);
}, [timestamp, abbreviated]);
return state;
}