1154 lines
36 KiB
TypeScript
1154 lines
36 KiB
TypeScript
// Metro module 8170 (f8171).
|
|
import ContentInventoryStore from "../content_inventory/ContentInventoryStore";
|
|
import ExperimentStore from "../experiments/ExperimentStore";
|
|
import GuildScheduledEventStore, { isGuildEventEnded, eventScheduledToStartWithin, isGuildScheduledEventActive } from "../guild_scheduled_events/GuildScheduledEventStore";
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import GuildAffinitiesStore from "../../stores/GuildAffinitiesStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import MessageStore from "../../stores/MessageStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import ReadStateStore from "../../stores/ReadStateStore";
|
|
import RelationshipStore from "../../stores/RelationshipStore";
|
|
import UserGuildSettingsStore from "../../stores/UserGuildSettingsStore";
|
|
import ICYMIFiltersStore from "./ICYMIFiltersStore";
|
|
import ICYMIUnreadStateStore from "./ICYMIUnreadStateStore";
|
|
import { GuildFeatures, Permissions, ChannelTypes } from "../../Constants";
|
|
import { ContentInventoryFeedKey } from "../content_inventory/ContentInventoryConstants";
|
|
import Durations from "../../utils/Durations";
|
|
import * as _ICYMIUtils from "./ICYMIUtils";
|
|
import { compareGravityUnreadIds, customStatusToContentInventoryEntry, hydrateItems, isItemUnreadInChannel, numberToCustomScore, ICYMICustomScore, createGravityMessageFromServer, generateHydrationId } from "./ICYMIUtils";
|
|
import { GAME_CONTENT_GUILD_ID, ICYMIItemTypes, ICYMI_PAGE_SIZE, MIN_ITEMS_FOR_NEW_PILL, SUPPORTED_ITEM_TYPES } from "./ICYMITypes";
|
|
import { ContentInventoryEntryType } from "../../_bundle/Module7909";
|
|
import { isEntryExpired } from "../content_inventory/utils";
|
|
import { isGamingLikeEntry } from "../content_inventory/ContentInventoryTypes";
|
|
import { ICYMIAnalytics } from "./ICYMIAnalytics";
|
|
import { makeDiscoverableGuild } from "../../utils/GuildDiscoveryUtils";
|
|
import { createMessageRecord } from "../messages/MessageRecordUtils";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
function $mk80003() {
|
|
return (a0) => a0.id;
|
|
}
|
|
function $mk80004($env) {
|
|
return (a0) => $env[0].has(a0.id);
|
|
}
|
|
function $mk80005($env) {
|
|
return (a0) => a0.type !== $env[0];
|
|
}
|
|
function $mk80006($env) {
|
|
return (a0, a1) => {
|
|
const r4 = $env;
|
|
const r8 = a1 + 1;
|
|
const r1 = r4[1];
|
|
const r5 = r4[2];
|
|
if (r8 * r1 < r5.length) {
|
|
r5.splice((a1 + 1) * r1, 0, a0);
|
|
} else {
|
|
r5.push(a0);
|
|
}
|
|
};
|
|
}
|
|
function $mk80015($env) {
|
|
return (a0) => {
|
|
const r5 = $env.$parent;
|
|
const r3 = r5[20].getReadTimestamp(a0.id) != null;
|
|
const type2 = a0.type;
|
|
const r14 = r5[0];
|
|
const r15 = r5[2];
|
|
const r23 = type2 === r14(r15[19]).ICYMIItemTypes.MESSAGE && a0.data.message_context?.external_content_application_id == null ? r3 ? r3 : !r14(r15[18]).isItemUnreadInChannel(a0.data.channel_id, a0.data.message_id) : r3;
|
|
L14: {
|
|
const r31 = $env;
|
|
if (r23) {
|
|
r31[0].push(a0);
|
|
} else {
|
|
if (a0.type === r14(r15[19]).ICYMIItemTypes.MESSAGE && a0.data.has_mention) {
|
|
r31[2].push(a0);
|
|
break L14;
|
|
}
|
|
r31[1].push(a0);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function $mk80018($env) {
|
|
return (a0) => {
|
|
const r2 = $env.$parent;
|
|
const isGuildItem = (0, r2[0])(r2[2][18]).isGuildItem(a0);
|
|
return isGuildItem ? a0.data.channel_id !== $env[0] : !isGuildItem;
|
|
};
|
|
}
|
|
function $mk80019($env) {
|
|
return (a0) => {
|
|
const r2 = $env.$parent;
|
|
const isGuildItem = (0, r2[0])(r2[2][18]).isGuildItem(a0);
|
|
return isGuildItem ? a0.data.guild_id !== $env[0] : !isGuildItem;
|
|
};
|
|
}
|
|
let injectItemsIntoList, injectRecommendedGuildsRow, finalizeNewDehydratedItemsContent, reload, getNewUnreadItems, maybeFilterChannelItems, maybeFilterGuildItems, c5188_25, c5188_26, c5188_65;
|
|
let $mk80016 = function() {
|
|
return (a0, a1) => compareGravityUnreadIds(a0.id, a1.id);
|
|
};
|
|
let env5188 = {};
|
|
const filterStaffGuild = function filterStaffGuild(a0) {
|
|
if (ICYMIFiltersStore.filterStaffContent()) {
|
|
L6: {
|
|
if (_ICYMIUtils.isGuildItem(a0)) {
|
|
if (a0.data.guild_id === GAME_CONTENT_GUILD_ID) {
|
|
return true;
|
|
}
|
|
const guild = GuildStore.getGuild(a0.data.guild_id);
|
|
if (guild != null && !guild.features.has(GuildFeatures.INTERNAL_EMPLOYEE_ONLY)) {
|
|
break L6;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return true;
|
|
};
|
|
injectItemsIntoList = function injectItemsIntoList(a0, a1, a2, a3) {
|
|
let env16301;
|
|
const r2 = env16301 = {};
|
|
env16301[0] = a2;
|
|
env16301[1] = 7;
|
|
const r7 = a0.filter($mk80005(r2));
|
|
env16301[2] = r7;
|
|
a1.forEach($mk80006(r2));
|
|
return r7;
|
|
};
|
|
injectRecommendedGuildsRow = function injectRecommendedGuildsRow() {
|
|
L15: {
|
|
env5188[45] = env5188[45].filter((item) => item.type !== ICYMIItemTypes.RECOMMENDED_GUILDS);
|
|
env5188[46] = env5188[46].filter((item) => item.type !== ICYMIItemTypes.RECOMMENDED_GUILDS);
|
|
if (env5188[48].length !== 0) {
|
|
const r4 = GuildStore.getGuildsArray().filter((item) => item.features.has(GuildFeatures.COMMUNITY)).length >= 5;
|
|
const readTimestamp = ICYMIUnreadStateStore.getReadTimestamp("recommendedGuilds");
|
|
if (r4 && readTimestamp != null && Date.now() - env5188[49] > c5188_25 && Date.now() - readTimestamp < c5188_26) {
|
|
break L15;
|
|
}
|
|
const r50 = {
|
|
id: "recommendedGuilds",
|
|
type: ICYMIItemTypes.RECOMMENDED_GUILDS,
|
|
score: 50
|
|
};
|
|
env5188[34][r50.id] = r50;
|
|
env5188[33][r50.id] = r50;
|
|
if (env5188[45].length === 0) {
|
|
env5188[46] = [r50, ...env5188[46]];
|
|
} else {
|
|
if (!(!r4 && env5188[45].length < 5) && !(r4 && env5188[45].length < 10)) {
|
|
if (r4) {
|
|
env5188[45].splice(Math.round(2 * Math.random()) + 3 - 1, 0, r50);
|
|
break L15;
|
|
}
|
|
env5188[45].splice(5, 0, r50);
|
|
break L15;
|
|
}
|
|
env5188[45] = [...env5188[45], r50];
|
|
}
|
|
}
|
|
}
|
|
};
|
|
finalizeNewDehydratedItemsContent = function finalizeNewDehydratedItemsContent() {
|
|
let id, type;
|
|
const set = new Set();
|
|
let c16302_0 = set;
|
|
env5188[30].forEach((item) => {
|
|
c16302_0.add(item.id);
|
|
});
|
|
if (env5188[43] != null) {
|
|
const r21 = set.has(env5188[43].id);
|
|
const r22 = env5188[43];
|
|
if (r21) {
|
|
id = r22.id;
|
|
type = env5188[43].type;
|
|
const r34 = env5188[30].findIndex((item) => item.id === id && item.type === type);
|
|
if (r34 !== -1) {
|
|
env5188[43] = env5188[30][r34];
|
|
const r41 = env5188[30].filter((item) => item.id !== id);
|
|
env5188[30] = r41;
|
|
env5188[30] = [env5188[43], ...r41];
|
|
}
|
|
} else {
|
|
env5188[30] = [r22, ...env5188[30]];
|
|
set.add(env5188[43].id);
|
|
}
|
|
}
|
|
env5188[30].forEach((item) => {
|
|
env5188[33][item.id] = item;
|
|
if (item.type === ICYMIItemTypes.CUSTOM_STATUS) {
|
|
if (RelationshipStore.isBlockedOrIgnored(item.data.user_id)) {
|
|
env5188[35][item.id] = true;
|
|
} else {
|
|
env5188[34][item.id] = customStatusToContentInventoryEntry(item);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
reload = function reload(a0) {
|
|
if (env5188[30].length > 0) {
|
|
env5188[27] = env5188[30];
|
|
env5188[30] = [];
|
|
env5188[31] = [];
|
|
}
|
|
env5188[38] = env5188[38] + 1;
|
|
if (a0 != null) {
|
|
env5188[45] = a0.newUnread;
|
|
env5188[46] = a0.newRead;
|
|
} else {
|
|
let env16303;
|
|
const r13 = env5188[27];
|
|
const r8 = env16303 = {
|
|
$parent: env5188
|
|
};
|
|
const r11 = [];
|
|
env16303[0] = r11;
|
|
const r9 = [];
|
|
env16303[1] = r9;
|
|
const r10 = [];
|
|
env16303[2] = r10;
|
|
r13.forEach($mk80015(r8));
|
|
const [r39, r40] = [[...r10, ...r9], r11.sort($mk80016())];
|
|
env5188[45] = r39;
|
|
env5188[46] = r40;
|
|
}
|
|
let c16304_0, c16304_1, c16304_2, c16304_3;
|
|
(function injectGuildEvents() {
|
|
const guildIds = GuildStore.getGuildIds();
|
|
const r5 = [];
|
|
loop1: for (const r14 of guildIds) {
|
|
const r41 = r14;
|
|
if (env5188[36][r14] != null && env5188[36][r41] < 0) {
|
|
continue;
|
|
}
|
|
const guildScheduledEventsForGuild = GuildScheduledEventStore.getGuildScheduledEventsForGuild(r41);
|
|
let r50 = 0;
|
|
for (const item of guildScheduledEventsForGuild) {
|
|
if ((0, isGuildEventEnded)(item)) {
|
|
continue;
|
|
}
|
|
if (item.channel_id != null && !PermissionStore.can(Permissions.VIEW_CHANNEL, ChannelStore.getChannel(item.channel_id))) {
|
|
continue;
|
|
}
|
|
const eventScheduledToStartWithin2 = eventScheduledToStartWithin;
|
|
if (!eventScheduledToStartWithin2(item, 2 * Durations.Seconds.DAY) && !(0, isGuildScheduledEventActive)(item)) {
|
|
continue;
|
|
}
|
|
if (env5188[34][item.id] == null) {
|
|
const r86 = env5188[34];
|
|
r86[item.id] = {
|
|
id: item.id,
|
|
type: require(dependencyMap[19]).ICYMIItemTypes.GUILD_EVENT,
|
|
score: 10,
|
|
event_id: item.id
|
|
};
|
|
}
|
|
const r99 = {
|
|
id: item.id,
|
|
type: require(dependencyMap[19]).ICYMIItemTypes.GUILD_EVENT,
|
|
score: 10,
|
|
data: null
|
|
};
|
|
let channel_id = item.channel_id;
|
|
if (channel_id == null) {
|
|
channel_id = void 0;
|
|
}
|
|
r99.data = {
|
|
guild_id: item.guild_id,
|
|
event_id: item.id,
|
|
channel_id
|
|
};
|
|
r5.push(r99);
|
|
const r112 = r50 + 1;
|
|
r50 = r112;
|
|
if (!(1 <= r112)) {
|
|
continue;
|
|
}
|
|
continue loop1;
|
|
}
|
|
}
|
|
let c26122_0, c26122_1;
|
|
r5.sort((a, b) => {
|
|
const guildAffinity = GuildAffinitiesStore.getGuildAffinity(a.data.guild_id);
|
|
const guildAffinity2 = GuildAffinitiesStore.getGuildAffinity(b.data.guild_id);
|
|
return (guildAffinity2 != null ? guildAffinity2.score : 0) - (guildAffinity != null ? guildAffinity.score : 0);
|
|
});
|
|
const r120 = [];
|
|
c26122_0 = r120;
|
|
const r121 = [];
|
|
c26122_1 = r121;
|
|
r5.forEach((item) => {
|
|
env5188[33][item.id] = item;
|
|
if (ICYMIUnreadStateStore.getReadTimestamp(item.id) != null) {
|
|
c26122_1.push(item);
|
|
} else {
|
|
c26122_0.push(item);
|
|
}
|
|
});
|
|
env5188[45] = injectItemsIntoList(env5188[45], r120, ICYMIItemTypes.GUILD_EVENT, 7);
|
|
env5188[46] = injectItemsIntoList(env5188[46], r121, ICYMIItemTypes.GUILD_EVENT, 7);
|
|
})();
|
|
c16304_0 = void 0;
|
|
c16304_1 = void 0;
|
|
c16304_2 = void 0;
|
|
c16304_3 = void 0;
|
|
c16304_0 = new Set();
|
|
c16304_1 = {};
|
|
const r53 = [];
|
|
c16304_2 = r53;
|
|
const r54 = [];
|
|
c16304_3 = r54;
|
|
let r60 = ContentInventoryStore.getFeed(ContentInventoryFeedKey.GLOBAL_FEED)?.entries;
|
|
if (r60 == null) {
|
|
r60 = [];
|
|
}
|
|
let env16305;
|
|
let env16306;
|
|
r60.sort((a, b) => a.rank - b.rank).slice(0, 5);
|
|
r60.forEach((item) => {
|
|
L16: {
|
|
if (!c16304_0.has(item.content.id)) {
|
|
if (item.content.content_type !== ContentInventoryEntryType.PLAYED_GAME && item.content.content_type !== ContentInventoryEntryType.CUSTOM_STATUS && item.content.content_type !== ContentInventoryEntryType.TOP_GAME) {
|
|
break L16;
|
|
}
|
|
if (!isEntryExpired(item.content)) {
|
|
if (isGamingLikeEntry(item.content)) {
|
|
if (c16304_1[item.content.author_id] == null) {
|
|
c16304_1[item.content.author_id] = new Set();
|
|
}
|
|
if (c16304_1[item.content.author_id].has(item.content.extra.application_id)) {
|
|
return void 0;
|
|
}
|
|
c16304_1[item.content.author_id].add(item.content.extra.application_id);
|
|
}
|
|
if (env5188[34][item.content.id] == null) {
|
|
env5188[34][item.content.id] = {
|
|
id: item.content.id,
|
|
type: ICYMIItemTypes.ACTIVITY,
|
|
score: 15,
|
|
activity: item.content
|
|
};
|
|
}
|
|
const r91 = {
|
|
id: item.content.id,
|
|
type: ICYMIItemTypes.ACTIVITY,
|
|
score: 15,
|
|
data: {
|
|
user_id: item.content.author_id,
|
|
content_id: item.content.id
|
|
}
|
|
};
|
|
c16304_0.add(item.content.id);
|
|
env5188[33][r91.id] = r91;
|
|
if (ICYMIUnreadStateStore.getReadTimestamp(r91.id) != null) {
|
|
c16304_3.push(r91);
|
|
} else {
|
|
c16304_2.push(r91);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const r14 = env5188[45];
|
|
const ACTIVITY = ICYMIItemTypes.ACTIVITY;
|
|
const r76 = env16305 = {};
|
|
env16305[0] = ACTIVITY;
|
|
env16305[1] = 5;
|
|
env16305[2] = void 0;
|
|
const r79 = r14.filter($mk80005(r76));
|
|
env16305[2] = r79;
|
|
r53.forEach($mk80006(r76));
|
|
env5188[45] = r79;
|
|
const r83 = env5188[46];
|
|
const ACTIVITY2 = ICYMIItemTypes.ACTIVITY;
|
|
const r88 = env16306 = {};
|
|
env16306[0] = ACTIVITY2;
|
|
env16306[1] = 5;
|
|
env16306[2] = void 0;
|
|
const r91 = r83.filter($mk80005(r88));
|
|
env16306[2] = r91;
|
|
r54.forEach($mk80006(r88));
|
|
env5188[46] = r91;
|
|
injectRecommendedGuildsRow();
|
|
if (env5188[32].load_id != null && env5188[28] !== env5188[32].load_id) {
|
|
ICYMIAnalytics.trackFeedLoaded({
|
|
newTrackingProps: env5188[32],
|
|
hasNewContent: env5188[40],
|
|
unreadFeedItems: env5188[45],
|
|
readFeedItems: env5188[46],
|
|
homeSessionId: "gravity"
|
|
});
|
|
let load_id = env5188[32].load_id;
|
|
if (load_id == null) {
|
|
load_id = null;
|
|
}
|
|
env5188[28] = load_id;
|
|
env5188[32] = {};
|
|
}
|
|
env5188[47] = 0;
|
|
if (env5188[45].length + env5188[46].length === 0) {
|
|
env5188[54] = true;
|
|
}
|
|
hydrateItems([...env5188[45], ...env5188[46]], 0, ICYMI_PAGE_SIZE);
|
|
env5188[51] = false;
|
|
};
|
|
getNewUnreadItems = function getNewUnreadItems(a0, a1) {
|
|
const r0 = [];
|
|
const set = new Set(env5188[27].map((item) => item.id));
|
|
for (const item of a0) {
|
|
if (item.type !== ICYMIItemTypes.RECOMMENDED_GUILDS && !set.has(item.id)) {
|
|
let r50 = ICYMIUnreadStateStore.getReadTimestamp(item.id) == null;
|
|
if (r50) {
|
|
let r57 = item.type !== ICYMIItemTypes.MESSAGE;
|
|
if (!r57) {
|
|
r57 = isItemUnreadInChannel(item.data.channel_id, item.data.message_id) && item.data.channel_id !== a1;
|
|
}
|
|
r50 = r57;
|
|
}
|
|
if (r50) {
|
|
r0.push(item);
|
|
}
|
|
}
|
|
}
|
|
return r0;
|
|
};
|
|
maybeFilterChannelItems = function maybeFilterChannelItems(a0, a1) {
|
|
if (numberToCustomScore(a1) === ICYMICustomScore.MUTED) {
|
|
let env16307;
|
|
let env16308;
|
|
let env16309;
|
|
let env16310;
|
|
let env16311;
|
|
const r14 = env5188[27];
|
|
const r15 = env16307 = {
|
|
$parent: env5188
|
|
};
|
|
env16307[0] = a0;
|
|
env5188[27] = r14.filter($mk80018(r15));
|
|
const r19 = env5188[45];
|
|
const r20 = env16308 = {
|
|
$parent: env5188
|
|
};
|
|
env16308[0] = a0;
|
|
env5188[45] = r19.filter($mk80018(r20));
|
|
const r24 = env5188[46];
|
|
const r25 = env16309 = {
|
|
$parent: env5188
|
|
};
|
|
env16309[0] = a0;
|
|
env5188[46] = r24.filter($mk80018(r25));
|
|
const r29 = env5188[30];
|
|
const r30 = env16310 = {
|
|
$parent: env5188
|
|
};
|
|
env16310[0] = a0;
|
|
env5188[30] = r29.filter($mk80018(r30));
|
|
const r34 = env5188[31];
|
|
const r35 = env16311 = {
|
|
$parent: env5188
|
|
};
|
|
env16311[0] = a0;
|
|
env5188[31] = r34.filter($mk80018(r35));
|
|
}
|
|
};
|
|
maybeFilterGuildItems = function maybeFilterGuildItems(a0, a1) {
|
|
if (numberToCustomScore(a1) === ICYMICustomScore.MUTED) {
|
|
let env16312;
|
|
let env16313;
|
|
let env16314;
|
|
let env16315;
|
|
let env16316;
|
|
const r14 = env5188[27];
|
|
const r15 = env16312 = {
|
|
$parent: env5188
|
|
};
|
|
env16312[0] = a0;
|
|
env5188[27] = r14.filter($mk80019(r15));
|
|
const r19 = env5188[45];
|
|
const r20 = env16313 = {
|
|
$parent: env5188
|
|
};
|
|
env16313[0] = a0;
|
|
env5188[45] = r19.filter($mk80019(r20));
|
|
const r24 = env5188[46];
|
|
const r25 = env16314 = {
|
|
$parent: env5188
|
|
};
|
|
env16314[0] = a0;
|
|
env5188[46] = r24.filter($mk80019(r25));
|
|
const r29 = env5188[30];
|
|
const r30 = env16315 = {
|
|
$parent: env5188
|
|
};
|
|
env16315[0] = a0;
|
|
env5188[30] = r29.filter($mk80019(r30));
|
|
const r34 = env5188[31];
|
|
const r35 = env16316 = {
|
|
$parent: env5188
|
|
};
|
|
env16316[0] = a0;
|
|
env5188[31] = r34.filter($mk80019(r35));
|
|
}
|
|
};
|
|
const handleReaction = function handleReaction(a0) {
|
|
const { type: type2, messageId, userId, emoji, reactionType } = a0;
|
|
const r17 = env5188[34][messageId];
|
|
if (r17 == null) {
|
|
return false;
|
|
}
|
|
if (r17.type !== ICYMIItemTypes.MESSAGE) {
|
|
return false;
|
|
}
|
|
const r1 = AuthenticationStore.getId() === userId;
|
|
r17.message = type2 === "MESSAGE_REACTION_ADD" ? r17.message.addReaction(emoji, r1, a0.colors, reactionType) : r17.message.removeReaction(emoji, r1, reactionType);
|
|
};
|
|
const handleAck = function handleAck({ channelId }) {
|
|
let r44;
|
|
let env16318;
|
|
const r9 = [];
|
|
let c16317_1 = r9;
|
|
const r21 = [];
|
|
let c16317_2 = r21;
|
|
env5188[45].forEach((item, index) => {
|
|
if (!(!(index > env5188[47]) && env5188[41]) && (item.type === ICYMIItemTypes.MESSAGE && item.data.channel_id === channelId)) {
|
|
c16317_1.push(item);
|
|
} else {
|
|
c16317_2.push(item);
|
|
}
|
|
});
|
|
const r5 = env5188[40];
|
|
const r16 = env5188[30];
|
|
const r24 = env16318 = {
|
|
$parent: env5188
|
|
};
|
|
const r14 = [];
|
|
env16318[0] = r14;
|
|
const r25 = [];
|
|
env16318[1] = r25;
|
|
const r26 = [];
|
|
env16318[2] = r26;
|
|
r16.forEach($mk80015(r24));
|
|
const [r40, ] = [[...r26, ...r25], r14.sort($mk80016())];
|
|
const newUnreadItems = getNewUnreadItems(r40, channelId);
|
|
env5188[31] = newUnreadItems;
|
|
if (env5188[41]) {
|
|
r44 = r5 && newUnreadItems.length >= MIN_ITEMS_FOR_NEW_PILL;
|
|
} else {
|
|
r44 = r5;
|
|
if (r5) {
|
|
const r45 = env5188[30];
|
|
const r51 = Date.now() - env5188[29];
|
|
const r59 = 6 * Durations.Millis.HOUR;
|
|
let r3 = false;
|
|
if (r51 > r59) {
|
|
let env16319;
|
|
const r60 = env16319 = {};
|
|
env16319[0] = new Set(r21.map($mk80003()));
|
|
r3 = r45.slice(0, 20).filter($mk80004(r60)).length >= 3;
|
|
}
|
|
r44 = r3;
|
|
}
|
|
}
|
|
env5188[40] = r44;
|
|
if (r9.length === 0 && r5 === env5188[40]) {
|
|
return false;
|
|
}
|
|
if (r9.length !== 0) {
|
|
env5188[45] = r21;
|
|
env5188[46] = [...env5188[46], ...r9];
|
|
}
|
|
};
|
|
c5188_25 = 1 * Durations.Millis.DAY;
|
|
c5188_26 = 3 * Durations.Millis.DAY;
|
|
env5188[27] = [];
|
|
env5188[28] = null;
|
|
env5188[29] = 0;
|
|
env5188[30] = [];
|
|
env5188[31] = [];
|
|
env5188[32] = {};
|
|
env5188[33] = {};
|
|
env5188[34] = {};
|
|
env5188[35] = {};
|
|
env5188[36] = {};
|
|
env5188[37] = {};
|
|
env5188[38] = 0;
|
|
env5188[39] = false;
|
|
env5188[40] = false;
|
|
env5188[41] = false;
|
|
env5188[42] = null;
|
|
env5188[43] = null;
|
|
env5188[44] = 0;
|
|
env5188[45] = [];
|
|
env5188[46] = [];
|
|
env5188[47] = 0;
|
|
env5188[48] = [];
|
|
env5188[49] = 0;
|
|
env5188[50] = true;
|
|
env5188[51] = false;
|
|
env5188[52] = new Set();
|
|
env5188[53] = false;
|
|
env5188[54] = false;
|
|
env5188[55] = 0;
|
|
env5188[56] = 0;
|
|
class ICYMIStore extends Module589.PersistedStore {
|
|
static displayName = "ICYMIStore";
|
|
static persistKey = "ICYMIStore";
|
|
constructor() {
|
|
super(...arguments);
|
|
}
|
|
initialize(a0) {
|
|
this.waitFor(AuthenticationStore, ChannelStore, ContentInventoryStore, ExperimentStore, GuildAffinitiesStore, GuildScheduledEventStore, GuildStore, ICYMIFiltersStore, ICYMIUnreadStateStore, MessageStore, PermissionStore, ReadStateStore, RelationshipStore, UserGuildSettingsStore);
|
|
if (a0 != null) {
|
|
let dehydratedItems = a0.dehydratedItems;
|
|
if (dehydratedItems == null) {
|
|
dehydratedItems = [];
|
|
}
|
|
env5188[27] = dehydratedItems;
|
|
dehydratedItems.forEach((dehydratedItem) => {
|
|
env5188[33][dehydratedItem.id] = dehydratedItem;
|
|
});
|
|
let customGuildScores = a0.customGuildScores;
|
|
if (customGuildScores == null) {
|
|
customGuildScores = {};
|
|
}
|
|
env5188[36] = customGuildScores;
|
|
let customChannelScoresByGuild = a0.customChannelScoresByGuild;
|
|
if (customChannelScoresByGuild == null) {
|
|
customChannelScoresByGuild = {};
|
|
}
|
|
env5188[37] = customChannelScoresByGuild;
|
|
let numOpens = a0.numOpens;
|
|
if (numOpens == null) {
|
|
numOpens = 0;
|
|
}
|
|
env5188[44] = numOpens;
|
|
let lastOpened = a0.lastOpened;
|
|
if (lastOpened == null) {
|
|
lastOpened = 0;
|
|
}
|
|
env5188[29] = lastOpened;
|
|
let lastJoinedRecommendedGuild = a0.lastJoinedRecommendedGuild;
|
|
if (lastJoinedRecommendedGuild == null) {
|
|
lastJoinedRecommendedGuild = 0;
|
|
}
|
|
env5188[49] = lastJoinedRecommendedGuild;
|
|
let lastTakenICYMISurvey2 = a0.lastTakenICYMISurvey;
|
|
if (lastTakenICYMISurvey2 == null) {
|
|
lastTakenICYMISurvey2 = 0;
|
|
}
|
|
env5188[56] = lastTakenICYMISurvey2;
|
|
}
|
|
}
|
|
getVersion() {
|
|
return env5188[38];
|
|
}
|
|
getDehydratedItems() {
|
|
return env5188[27];
|
|
}
|
|
getNewDehydratedItems() {
|
|
return env5188[30];
|
|
}
|
|
getDehydratedItem(a0) {
|
|
let r4 = env5188[33][a0];
|
|
if (r4 == null) {
|
|
r4 = null;
|
|
}
|
|
return r4;
|
|
}
|
|
getHydratedItem(a0) {
|
|
let r4 = env5188[34][a0];
|
|
if (r4 == null) {
|
|
r4 = null;
|
|
}
|
|
return r4;
|
|
}
|
|
getMessage(a0) {
|
|
const r7 = env5188[34][a0];
|
|
return r7 == null ? null : r7.type === ICYMIItemTypes.MESSAGE ? r7.message : null;
|
|
}
|
|
getHydratedItems() {
|
|
return env5188[34];
|
|
}
|
|
getUnreadDisplayItems() {
|
|
return env5188[45];
|
|
}
|
|
getNewUnreadDehydratedItems() {
|
|
return env5188[31];
|
|
}
|
|
getReadDisplayItems() {
|
|
return env5188[46];
|
|
}
|
|
getNextIndexToHydrate() {
|
|
return env5188[47];
|
|
}
|
|
getMissingItems() {
|
|
return env5188[35];
|
|
}
|
|
customMuted(a0, a1) {
|
|
return this.getCustomGuildScore(a0) === ICYMICustomScore.MUTED || this.getCustomChannelScore(a0, a1) === ICYMICustomScore.MUTED;
|
|
}
|
|
getCustomChannelScore(a0, a1) {
|
|
return env5188[37][a0] != null && env5188[37][a0][a1] != null ? numberToCustomScore(env5188[37][a0][a1]) : ICYMICustomScore.UNKNOWN;
|
|
}
|
|
getCustomGuildScore(a0) {
|
|
let r5 = env5188[36][a0];
|
|
if (r5 == null) {
|
|
r5 = 0;
|
|
}
|
|
return r5;
|
|
}
|
|
getCustomGuildScores() {
|
|
return env5188[36];
|
|
}
|
|
hasNewContent() {
|
|
return env5188[40];
|
|
}
|
|
getCurrentStatusAttachments(a0) {
|
|
return env5188[42] != null && env5188[42][0] === a0 ? env5188[42][1] : [];
|
|
}
|
|
getLoadId() {
|
|
return env5188[28];
|
|
}
|
|
hasOpenedEnoughTimes() {
|
|
return env5188[44] === 5;
|
|
}
|
|
hasOpened() {
|
|
return env5188[41];
|
|
}
|
|
getDiscoverableGuilds() {
|
|
return env5188[48];
|
|
}
|
|
videosMuted() {
|
|
return env5188[50];
|
|
}
|
|
isRefreshing() {
|
|
return env5188[51];
|
|
}
|
|
isHydrating() {
|
|
return env5188[52].size > 0;
|
|
}
|
|
notificationItem() {
|
|
return env5188[43];
|
|
}
|
|
getIsTabFocused() {
|
|
return env5188[53];
|
|
}
|
|
isFirstPageHydrated() {
|
|
return env5188[54];
|
|
}
|
|
lastScrollEvent() {
|
|
return env5188[55];
|
|
}
|
|
lastTakenICYMISurvey() {
|
|
return env5188[56];
|
|
}
|
|
getIndexInHydratedFeed(a0) {
|
|
return a0 !== "recommended_guilds" && a0 !== "recommendedGuilds" ? [...env5188[45], ...env5188[46]].filter((item) => env5188[34][item.id] != null).findIndex((item) => item.id === a0) : [...env5188[45], ...env5188[46]].findIndex((item) => item.type === ICYMIItemTypes.RECOMMENDED_GUILDS);
|
|
}
|
|
getState() {
|
|
return {
|
|
dehydratedItems: env5188[27],
|
|
numOpens: env5188[44],
|
|
customGuildScores: env5188[36],
|
|
customChannelScoresByGuild: env5188[37],
|
|
lastOpened: env5188[29],
|
|
lastJoinedRecommendedGuild: env5188[49],
|
|
lastTakenICYMISurvey: env5188[56]
|
|
};
|
|
}
|
|
}
|
|
c5188_65 = ICYMIStore;
|
|
const r199 = new ICYMIStore(Dispatcher, {
|
|
LOGOUT: function handleLogout() {
|
|
env5188[27] = [];
|
|
env5188[30] = [];
|
|
env5188[31] = [];
|
|
env5188[33] = {};
|
|
env5188[32] = {};
|
|
env5188[34] = {};
|
|
env5188[35] = {};
|
|
env5188[28] = null;
|
|
env5188[36] = {};
|
|
env5188[37] = {};
|
|
env5188[38] = 0;
|
|
env5188[39] = false;
|
|
env5188[40] = false;
|
|
env5188[41] = false;
|
|
env5188[45] = [];
|
|
env5188[46] = [];
|
|
env5188[47] = 0;
|
|
env5188[29] = 0;
|
|
env5188[49] = 0;
|
|
env5188[50] = true;
|
|
env5188[51] = false;
|
|
env5188[52] = new Set();
|
|
env5188[43] = null;
|
|
env5188[53] = false;
|
|
env5188[54] = false;
|
|
env5188[42] = null;
|
|
env5188[55] = 0;
|
|
},
|
|
LOAD_ICYMI_FROM_NOTIFICATION: function handleLoadICYMIFromNotification({ messageItem, customStatusItem }) {
|
|
if (customStatusItem != null) {
|
|
env5188[43] = customStatusItem;
|
|
if (env5188[28] != null) {
|
|
env5188[30] = env5188[30].length > 0 ? env5188[30] : [...env5188[27]];
|
|
finalizeNewDehydratedItemsContent();
|
|
reload();
|
|
}
|
|
return true;
|
|
}
|
|
if (messageItem != null) {
|
|
const r7 = {
|
|
id: messageItem.message.id,
|
|
type: ICYMIItemTypes.MESSAGE,
|
|
score: 50,
|
|
data: {
|
|
channel_id: messageItem.channel_id,
|
|
message_id: messageItem.message.id,
|
|
guild_id: messageItem.guild_id,
|
|
channel_type: ChannelTypes.GUILD_TEXT
|
|
}
|
|
};
|
|
env5188[33][messageItem.message.id] = r7;
|
|
env5188[34][messageItem.message.id] = {
|
|
...r7,
|
|
message: createMessageRecord(messageItem.message)
|
|
};
|
|
if (env5188[28] == null && env5188[32] == null) {
|
|
let env16321;
|
|
const r49 = [r7, ...env5188[27]];
|
|
env5188[27] = r49;
|
|
const r54 = env16321 = {
|
|
$parent: env5188
|
|
};
|
|
const r55 = [];
|
|
env16321[0] = r55;
|
|
const r56 = [];
|
|
env16321[1] = r56;
|
|
const r57 = [];
|
|
env16321[2] = r57;
|
|
r49.forEach($mk80015(r54));
|
|
const [r76, r77] = [[...r57, ...r56], r55.sort($mk80016())];
|
|
env5188[45] = r76;
|
|
env5188[46] = r77;
|
|
} else {
|
|
env5188[30] = [r7, ...env5188[30]];
|
|
reload();
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
LOAD_ICYMI_DEHYDRATED: function handleLoadDehydrated(a0) {
|
|
let newRead, newUnread;
|
|
let c16322_0;
|
|
let env16323;
|
|
L17: {
|
|
const { items, loadId, startTime, isInitialLoad, isReloading } = a0;
|
|
c16322_0 = void 0;
|
|
c16322_0 = new Set(SUPPORTED_ITEM_TYPES);
|
|
env5188[30] = items.filter((item) => c16322_0.has(item.type)).filter(filterStaffGuild).map((item) => {
|
|
if (item.type === ICYMIItemTypes.MESSAGE && item.data.message_context != null) {
|
|
const r1 = item.data.message_context.reply_message_id != null && parseInt(item.data.message_context.reply_message_id) !== 0;
|
|
const message_context = {};
|
|
if (r1) {
|
|
message_context.reply_message_id = item.data.message_context.reply_message_id;
|
|
}
|
|
if (item.data.message_context.before_message_id != null && parseInt(item.data.message_context.before_message_id) !== 0) {
|
|
message_context.before_message_id = item.data.message_context.before_message_id;
|
|
}
|
|
if (item.data.message_context.after_message_id != null && parseInt(item.data.message_context.after_message_id) !== 0) {
|
|
message_context.after_message_id = item.data.message_context.after_message_id;
|
|
}
|
|
if (item.data.message_context.external_content_application_id != null && parseInt(item.data.message_context.external_content_application_id) !== 0) {
|
|
message_context.external_content_application_id = item.data.message_context.external_content_application_id;
|
|
}
|
|
if (item.data.message_context.reference_message_id != null && parseInt(item.data.message_context.reference_message_id) !== 0) {
|
|
message_context.reference_message_id = item.data.message_context.reference_message_id;
|
|
}
|
|
item.data.message_context = message_context;
|
|
}
|
|
return item;
|
|
});
|
|
finalizeNewDehydratedItemsContent();
|
|
env5188[32] = {
|
|
load_id: loadId,
|
|
load_time_millis: Date.now() - startTime,
|
|
feed_item_ids: env5188[30].map((item) => item.id)
|
|
};
|
|
const r45 = env5188[30];
|
|
const r46 = env16323 = {
|
|
$parent: env5188
|
|
};
|
|
const r47 = [];
|
|
env16323[0] = r47;
|
|
const r48 = [];
|
|
env16323[1] = r48;
|
|
const r49 = [];
|
|
env16323[2] = r49;
|
|
r45.forEach($mk80015(r46));
|
|
[newUnread, newRead] = [[...r49, ...r48], r47.sort($mk80016())];
|
|
const newUnreadItems = getNewUnreadItems(newUnread);
|
|
env5188[31] = newUnreadItems;
|
|
if (env5188[41]) {
|
|
const r70 = env5188[38];
|
|
if (r70 !== 0 && !isInitialLoad) {
|
|
if (r70 > 0) {
|
|
env5188[43] = null;
|
|
}
|
|
const r76 = newUnreadItems.length > MIN_ITEMS_FOR_NEW_PILL;
|
|
if (!isReloading) {
|
|
env5188[40] = r76;
|
|
}
|
|
if (!r76) {
|
|
break L17;
|
|
}
|
|
hydrateItems([...newUnread, ...newRead], 0, ICYMI_PAGE_SIZE);
|
|
if (newUnread.length + newRead.length !== 0) {
|
|
break L17;
|
|
}
|
|
env5188[54] = true;
|
|
break L17;
|
|
}
|
|
}
|
|
env5188[38] = 0;
|
|
if (!env5188[53]) {
|
|
const r97 = env5188[30];
|
|
const r102 = Date.now() - env5188[29];
|
|
const r109 = 6 * Durations.Millis.HOUR;
|
|
let r110 = false;
|
|
if (r102 > r109) {
|
|
let env16324;
|
|
const r111 = env16324 = {};
|
|
env16324[0] = new Set(newUnread.map($mk80003()));
|
|
r110 = r97.slice(0, 20).filter($mk80004(r111)).length >= 3;
|
|
}
|
|
if (r110) {
|
|
env5188[40] = true;
|
|
env5188[39] = true;
|
|
} else {
|
|
env5188[40] = false;
|
|
}
|
|
} else {
|
|
env5188[40] = false;
|
|
}
|
|
reload({
|
|
newUnread,
|
|
newRead
|
|
});
|
|
}
|
|
ICYMIAnalytics.trackFeedLoaded({
|
|
newTrackingProps: env5188[32],
|
|
hasNewContent: env5188[40],
|
|
unreadFeedItems: newUnread,
|
|
readFeedItems: newRead,
|
|
homeSessionId: env5188[53] ? "foreground_load" : "background_load"
|
|
});
|
|
},
|
|
LOAD_ICYMI_HYDRATED: function handleLoadHydratedItems({ messageItems, activityItems, requestMessageItems, requestActivityItems, startingIndex, endingIndex }) {
|
|
let c16325_1;
|
|
c16325_1 = void 0;
|
|
env5188[54] = true;
|
|
env5188[34] = {
|
|
...env5188[34]
|
|
};
|
|
let c16325_0 = messageItems.reduce((acc, messageItem) => {
|
|
acc[messageItem.message.id] = messageItem;
|
|
return acc;
|
|
}, {});
|
|
c16325_1 = activityItems.reduce((acc, activityItem) => {
|
|
acc[activityItem.id] = activityItem;
|
|
return acc;
|
|
}, {});
|
|
requestMessageItems.forEach((requestMessageItem) => {
|
|
const r13 = c16325_0[requestMessageItem.message_id];
|
|
if (r13 != null) {
|
|
let r7 = env5188[33][requestMessageItem.message_id];
|
|
if (r7 == null) {
|
|
r7 = {
|
|
id: requestMessageItem.message_id,
|
|
type: ICYMIItemTypes.MESSAGE,
|
|
score: -1,
|
|
data: {
|
|
guild_id: r13.guild_id,
|
|
channel_id: r13.channel_id,
|
|
message_id: r13.message.id,
|
|
channel_type: ChannelTypes.GUILD_TEXT,
|
|
has_mention: false
|
|
}
|
|
};
|
|
}
|
|
const message = MessageStore.getMessage(r13.channel_id, r13.message.id);
|
|
if (message != null) {
|
|
env5188[34][r13.message.id] = {
|
|
...createGravityMessageFromServer(r13, r7),
|
|
message
|
|
};
|
|
} else {
|
|
env5188[34][r13.message.id] = createGravityMessageFromServer(r13, r7);
|
|
}
|
|
} else {
|
|
env5188[35][requestMessageItem.message_id] = true;
|
|
}
|
|
});
|
|
requestActivityItems.forEach((requestActivityItem) => {
|
|
const activity = c16325_1[requestActivityItem.content_id];
|
|
if (activity != null) {
|
|
const r15 = env5188[33][requestActivityItem.content_id];
|
|
if (r15 != null) {
|
|
env5188[34][activity.id] = {
|
|
...r15,
|
|
activity
|
|
};
|
|
} else {
|
|
env5188[35][requestActivityItem.content_id] = true;
|
|
}
|
|
} else {
|
|
env5188[35][requestActivityItem.content_id] = true;
|
|
}
|
|
});
|
|
if (startingIndex === env5188[47]) {
|
|
env5188[47] = endingIndex;
|
|
}
|
|
env5188[52].delete(generateHydrationId(startingIndex, endingIndex));
|
|
},
|
|
LOAD_ICYMI_CUSTOM_SCORES: function handleLoadCustomScores(a0) {
|
|
for (const score of a0.scores) {
|
|
env5188[36][score.guild_id] = score.guild_score;
|
|
maybeFilterGuildItems(score.guild_id, score.guild_score);
|
|
for (const item of Object.keys(score.custom_channel_scores)) {
|
|
if (env5188[37][score.guild_id] == null) {
|
|
env5188[37][score.guild_id] = {};
|
|
}
|
|
const r56 = env5188[37];
|
|
const r14 = r56[score.guild_id];
|
|
r14[item] = score.custom_channel_scores[item];
|
|
maybeFilterChannelItems(item, score.custom_channel_scores[item]);
|
|
}
|
|
}
|
|
env5188[36] = {
|
|
...env5188[36]
|
|
};
|
|
env5188[37] = {
|
|
...env5188[37]
|
|
};
|
|
},
|
|
LOAD_ICYMI_RECOMMENDED_GUILDS: function loadICYMIRecommendedGuilds(a0) {
|
|
env5188[48] = a0.guilds.map((guild) => makeDiscoverableGuild(guild.guild));
|
|
injectRecommendedGuildsRow();
|
|
},
|
|
ICYMI_CUSTOM_SCORES_UPDATED: function handleCustomScoresUpdated({ channelScores, guildId, guildScore }) {
|
|
if (guildScore != null) {
|
|
env5188[36][guildId] = guildScore;
|
|
maybeFilterGuildItems(guildId, guildScore);
|
|
env5188[36] = {
|
|
...env5188[36]
|
|
};
|
|
}
|
|
if (channelScores != null) {
|
|
channelScores.forEach(({ channelId: channelId2, score }) => {
|
|
if (env5188[37][guildId] == null) {
|
|
env5188[37][guildId] = {};
|
|
}
|
|
env5188[37][guildId][channelId2] = score;
|
|
maybeFilterChannelItems(channelId2, score);
|
|
env5188[37] = {
|
|
...env5188[37]
|
|
};
|
|
});
|
|
}
|
|
},
|
|
RELOAD_ICYMI: function handleReloadTab() {
|
|
if (env5188[30].length === 0) {
|
|
return false;
|
|
}
|
|
reload();
|
|
env5188[40] = false;
|
|
},
|
|
ICYMI_TAB_OPENED: function handleGravityTabOpened() {
|
|
env5188[41] = true;
|
|
env5188[29] = Date.now();
|
|
if (env5188[39]) {
|
|
env5188[39] = false;
|
|
env5188[40] = false;
|
|
}
|
|
if (env5188[44] < 5) {
|
|
env5188[44] = env5188[44] + 1;
|
|
}
|
|
},
|
|
ICYMI_FEEDBACK_GIVEN: function handleGravityFeedback() {
|
|
env5188[44] = 6;
|
|
},
|
|
MESSAGE_REACTION_ADD: handleReaction,
|
|
MESSAGE_REACTION_ADD_MANY: function handleReactionBatch({ messageId, reactions }) {
|
|
const r8 = env5188[34][messageId];
|
|
if (r8 == null) {
|
|
return false;
|
|
}
|
|
if (r8.type !== ICYMIItemTypes.MESSAGE) {
|
|
return false;
|
|
}
|
|
r8.message = r8.message.addReactionBatch(reactions, AuthenticationStore.getId());
|
|
},
|
|
MESSAGE_REACTION_REMOVE: handleReaction,
|
|
MESSAGE_REACTION_REMOVE_ALL: function handleRemoveAllReactions(a0) {
|
|
const r9 = env5188[34][a0.messageId];
|
|
let r10 = r9 != null;
|
|
if (r10) {
|
|
let r17 = r9.type === ICYMIItemTypes.MESSAGE;
|
|
if (r17) {
|
|
r9.message = r9.message.set("reactions", []);
|
|
r17 = void 0;
|
|
}
|
|
r10 = r17;
|
|
}
|
|
return r10;
|
|
},
|
|
MESSAGE_REACTION_REMOVE_EMOJI: function handleRemoveEmojiReactions({ messageId, emoji }) {
|
|
const r9 = env5188[34][messageId];
|
|
let r10 = r9 != null;
|
|
if (r10) {
|
|
let r17 = r9.type === ICYMIItemTypes.MESSAGE;
|
|
if (r17) {
|
|
r9.message = r9.message.removeReactionsForEmoji(emoji);
|
|
r17 = void 0;
|
|
}
|
|
r10 = r17;
|
|
}
|
|
return r10;
|
|
},
|
|
CHANNEL_ACK: handleAck,
|
|
MESSAGE_ACK: handleAck,
|
|
ICYMI_JOINED_RECOMMENDED_GUILD: function handleJoinedRecommendedGuild() {
|
|
env5188[49] = Date.now();
|
|
},
|
|
ICYMI_SET_VIDEOS_MUTED: function handleSetVideosMuted(a0) {
|
|
env5188[50] = a0.muted;
|
|
},
|
|
ICYMI_SET_REFRESHING: function handleSetRefreshing(a0) {
|
|
env5188[51] = a0.refreshing;
|
|
},
|
|
LOAD_ICYMI_HYDRATED_ATTEMPT: function handleLoadHydratedAttempt(a0) {
|
|
env5188[52].add(a0.hydrationId);
|
|
},
|
|
LOAD_ICYMI_HYDRATED_FAILED: function handleLoadHydratedFailed(a0) {
|
|
env5188[52].delete(a0.hydrationId);
|
|
},
|
|
ICYMI_SET_FOCUSED_TAB: function handleSetFocusedTab(a0) {
|
|
env5188[53] = a0.focused;
|
|
},
|
|
LOAD_ICYMI_CURRENT_STATUS_MEDIA: function handleLoadCurrentStatusMedia({ attachments, createdAtMs }) {
|
|
env5188[42] = attachments != null ? attachments.length !== 0 ? [createdAtMs, [...attachments]] : null : null;
|
|
},
|
|
ICYMI_SCROLL_EVENT: function handleScrollEvent(a0) {
|
|
env5188[55] = a0.timestamp;
|
|
},
|
|
ICYMI_TAKE_SURVEY: function handleTakeSurvey(a0) {
|
|
env5188[56] = a0.takenAt;
|
|
}
|
|
});
|
|
export default r199;
|