Files
discord-decomp/sources/modules/icymi/useICYMIItems.tsx
T
2026-07-27 16:20:00 +03:00

335 lines
12 KiB
TypeScript

/* Metro module 14849; source: modules/icymi/useICYMIItems.tsx; dependencies: [31, 9569, 7230, 566, 9580, 2] */
function _fun112218(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#112218, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15046:6, offset: 0x023bf748, size: 148 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importAll(31) /* metro dependency 31 */;
const icymiStore = importDefault(9569) /* metro dependency 9569: ICYMIStore */;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/icymi/useICYMIItems.tsx');
exports.default = useICYMIItems;
}
function createItem(a0, a1, a2) { // fn#112219, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15046:120, offset: 0x023bf7dc, size: 833 bytes, params: 4, frame: 17
var r0;
var object2;
var id;
var JSON;
var message;
var data;
var object3;
const type = a1.type;
const ICYMIItemTypes = (require(7230) /* metro dependency 7230: ICYMITypes */).ICYMIItemTypes;
const MESSAGE = ICYMIItemTypes.MESSAGE;
if (MESSAGE === type) {
message = a1.message;
id = message.id;
message = a1.message;
if (id !== message.channel_id) {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
data = a0.data;
object2.channelType = data.channel_type;
object3 = {kind: 'message'};
object3.message = a1.message;
data = a0.data;
object3.mentioned = data.has_mention;
data = a0.data;
object3.messageContext = data.message_context;
object2.data = object3;
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
r0 = object2;
} else if (a1.threadChannel != null) {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
object2.channelType = a0.data.channel_type;
object2.data = {kind: 'forumThread', message: a1.message, threadChannel: a1.threadChannel};
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
r0 = object2;
} else {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
data = a0.data;
object2.channelType = data.channel_type;
object3 = {kind: 'message'};
object3.message = a1.message;
data = a0.data;
object3.mentioned = data.has_mention;
data = a0.data;
object3.messageContext = data.message_context;
object2.data = object3;
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
r0 = object2;
}
return r0;
}
const ACTIVITY = ICYMIItemTypes.ACTIVITY;
if (ACTIVITY === type) {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
object2.data = {kind: 'contentInventory', content: a1.activity};
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
return object2;
}
const CUSTOM_STATUS = ICYMIItemTypes.CUSTOM_STATUS;
if (CUSTOM_STATUS === type) {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
object2.data = {kind: 'contentInventory', content: a1.activity};
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
return object2;
}
const GUILD_EVENT = ICYMIItemTypes.GUILD_EVENT;
if (GUILD_EVENT === type) {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
object2.data = {kind: 'guildEvent', eventId: a1.event_id};
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
return object2;
}
const RECOMMENDED_GUILDS = ICYMIItemTypes.RECOMMENDED_GUILDS;
if (RECOMMENDED_GUILDS === type) {
object2 = {};
object2.id = a0.id;
object2.timestamp = global.Date.now();
object2.data = {kind: 'recommendedGuilds'};
object2.score = a0.score;
JSON = global.JSON;
object2.debugScore = JSON.stringify(a0.score_components);
object2.unread = a2;
return object2;
}
return null;
}
function useICYMIItems() { // fn#112220, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15046:1415, offset: 0x023bfb1d, size: 778 bytes, params: 1, frame: 38
var r8;
var r18;
var r0;
var reference_message_id;
var r23;
var r9;
var r12;
var r20;
var property;
var value5;
var id;
var property2;
var value6;
var type;
const ICYMIItemTypes = (require(7230) /* metro dependency 7230: ICYMITypes */).ICYMIItemTypes;
var MESSAGE;
var value7;
var data;
var message_context;
var value8;
var message_id;
var property3;
var item;
var value9;
var value10;
var property4;
var value11;
var value12;
var value13;
var property5;
var item2;
var value14;
const value2 = undefined;
const unreadDisplayItems = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore],
function() {
return ICYMIStore.getUnreadDisplayItems();
});
const readDisplayItems = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore],
function() {
return ICYMIStore.getReadDisplayItems();
});
const nextIndexToHydrate = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore],
function() {
return ICYMIStore.getNextIndexToHydrate();
});
const value3 = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([ICYMIStore], function() {
return ICYMIStore.getHydratedItems();
});
const missingItems = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore], function() {
return ICYMIStore.getMissingItems();
});
env0_3.useEffect(_fun112226, [readDisplayItems]);
items3 = [];
const items2 = [];
let length = unreadDisplayItems.length;
const value4 = 0;
if (value4 < length) {
r8 = value4;
r18 = value4;
while (true) {
if (r18 >= nextIndexToHydrate) {
r9 = r18;
break;
}
property = unreadDisplayItems[r8];
value5 = typeof r18 === 'bigint' ? r18 + 1n : +r18 + 1;
id = property.id;
if (missingItems[id]) {
continue;
}
id = property.id;
property2 = value3[id];
value6 = property2 == null;
if (!value6) {
r0 = value6;
continue;
}
type = property.type;
MESSAGE = ICYMIItemTypes.MESSAGE;
value7 = type === MESSAGE;
r0 = value7;
if (!r0) {
continue;
}
data = property.data;
message_context = data.message_context;
if (message_context == null) {
reference_message_id = value2;
continue;
}
reference_message_id = message_context.reference_message_id;
value8 = reference_message_id != null;
r0 = value8;
if (!r0) {
r23 = property2;
continue;
}
data = property.data;
message_id = data.message_id;
property3 = value3[message_id];
r23 = property3;
if (r23 == null) {
continue;
}
item = createItem(property, r23, true);
if (item == null) {
continue;
}
items3.push(item);
value9 = typeof r8 === 'bigint' ? r8 + 1n : +r8 + 1;
length = unreadDisplayItems.length;
if (value9 < length) {
r8 = value9;
r18 = value5;
continue;
}
r9 = value5;
break;
}
} else {
r9 = value4;
}
length = readDisplayItems.length;
if (value4 < length) {
r12 = value4;
while (true) {
if (r9 >= nextIndexToHydrate) {
break;
}
property = readDisplayItems[r12];
value10 = typeof r9 === 'bigint' ? r9 + 1n : +r9 + 1;
id = property.id;
if (missingItems[id]) {
continue;
}
id = property.id;
property4 = value3[id];
value11 = property4 == null;
if (!value11) {
r0 = value11;
continue;
}
type = property.type;
MESSAGE = ICYMIItemTypes.MESSAGE;
value12 = type === MESSAGE;
r0 = value12;
if (!r0) {
continue;
}
data = property.data;
message_context = data.message_context;
if (message_context == null) {
reference_message_id = value2;
continue;
}
reference_message_id = message_context.reference_message_id;
value13 = reference_message_id != null;
r0 = value13;
if (!r0) {
r20 = property4;
continue;
}
data = property.data;
message_id = data.message_id;
property5 = value3[message_id];
r20 = property5;
if (r20 == null) {
continue;
}
item2 = createItem(property, r20, false);
if (item2 == null) {
continue;
}
items2.push(item2);
value14 = typeof r12 === 'bigint' ? r12 + 1n : +r12 + 1;
length = readDisplayItems.length;
if (value14 < length) {
r9 = value10;
r12 = value14;
continue;
}
break;
}
}
return {unreadItems: items3, readItems: items2,
allUnreadItemsHydrated: nextIndexToHydrate >= unreadDisplayItems.length};
}
function _fun112226() { // fn#112226, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15046:1780, offset: 0x023bfe88, size: 97 bytes, params: 1, frame: 16
var environment;
const Date = global.Date;
let value = Date.now();
const readDisplayItemsBinding = readDisplayItems;
const env0_0 = value + readDisplayItemsBinding.length;
value = environment.__proto__;
value = importDefault(9580) /* metro dependency 9580: ICYMIActionCreators */;
value.ackGravityItems(readDisplayItemsBinding.map(_fun112227, true));
}
function _fun112227({id}) { // fn#112227, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15046:1844, offset: 0x023bfee9, size: 38 bytes, params: 2, frame: 4
const binding = env0_0;
const value2 = typeof binding === 'bigint' ? binding : +binding;
env0_0 = typeof value2 === 'bigint' ? value2 - 1n : +value2 - 1;
return {id: id, timestamp: value2};
}