158 lines
5.6 KiB
TypeScript
158 lines
5.6 KiB
TypeScript
// 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;
|
|
};
|