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

322 lines
12 KiB
TypeScript

/* Metro module 9578; source: modules/icymi/ICYMIUnreadStateStore.tsx; dependencies: [6, 7, 15, 17, 18, 672, 7230, 9579, 566, 694, 2] */
function _fun74947(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#74947, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:6, offset: 0x01d9e3b5, size: 377 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_74953 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_2 = importDefault(6) /* metro dependency 6 */;
const env0_3 = importDefault(7) /* metro dependency 7 */;
const env0_4 = importDefault(15) /* metro dependency 15 */;
const env0_5 = importDefault(17) /* metro dependency 17 */;
const env0_6 = importDefault(18) /* metro dependency 18 */;
const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
const DAY = Millis.DAY;
const env0_7 = 7 * DAY;
object = {readIdToTimestampMap: {}};
const DeviceSettingsStore = (importDefault(566) /* metro dependency 566: flux */).DeviceSettingsStore;
let value = _fun74954(DeviceSettingsStore);
value.displayName = 'ICYMIUnreadStateStore';
value.persistKey = 'ICYMIUnreadStateStore';
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {ICYMI_ACK_ITEMS: function({items,
override}) {
items.forEach(_fun74962);
}, LOAD_ICYMI_DEHYDRATED: LOAD_ICYMI_DEHYDRATED_74963, CLEAR_ICYMI_READ_STATES: CLEAR_ICYMI_READ_STATES});
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/icymi/ICYMIUnreadStateStore.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_74948() { // fn#74948, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:150, offset: 0x01d9e52e, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_74948_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _createForOfIteratorHelperLoose_74951(a0, a1) { // fn#74951, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:343, offset: 0x01d9e590, size: 372 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun74952;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_74953(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_74953(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_74953(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun74952;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
}
function _fun74954(a0) { // fn#74954, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:1314, offset: 0x01d9e704, size: 147 bytes, params: 2, frame: 16
const closure = ICYMIUnreadStateStore;
env0_6(closure, a0);
return env0_3(closure, [{key: 'initialize', value: value_74956}, {key: 'getReadTimestamp', value: value_74958},
{key: 'getState', value: value_74959}, {key: 'getUserAgnosticState', value: value_74960}]);
}
function ICYMI_ACK_ITEMS({items, override}) { // fn#74961, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:2301, offset: 0x01d9e888, size: 42 bytes, params: 2, frame: 11
items.forEach(_fun74962);
}
function LOAD_ICYMI_DEHYDRATED_74963({items}) { // fn#74963, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:2479, offset: 0x01d9e908, size: 265 bytes, params: 2, frame: 25
var r3;
var external_content_application_id;
var r11;
var value5;
var type;
var ICYMIItemTypes;
var MESSAGE;
var readIdToTimestampMap;
var id;
var value6;
var data;
var message_context;
var value7;
var moduleValue;
var isItemUnreadInChannel;
var channel_id;
var message_id;
var isItemUnreadInChannel2;
var value8;
const value3 = _createForOfIteratorHelperLoose_74951(items);
const value4 = value3();
let done = value4.done;
if (!done) {
r3 = value4;
while (true) {
value5 = r3.value;
type = value5.type;
ICYMIItemTypes = (require(7230) /* metro dependency 7230: ICYMITypes */).ICYMIItemTypes;
MESSAGE = ICYMIItemTypes.MESSAGE;
if (type === MESSAGE) {
readIdToTimestampMap = env0_8.readIdToTimestampMap;
id = value5.id;
value6 = readIdToTimestampMap[id] != null;
if (value6) {
r11 = value6;
continue;
}
data = value5.data;
message_context = data.message_context;
if (message_context == null) {
external_content_application_id = undefined;
continue;
}
external_content_application_id = message_context.external_content_application_id;
value7 = external_content_application_id != null;
r11 = value7;
if (r11) {
continue;
}
moduleValue = require(9579) /* metro dependency 9579: ICYMIUtils */;
isItemUnreadInChannel = moduleValue.isItemUnreadInChannel;
data = value5.data;
channel_id = data.channel_id;
data = value5.data;
message_id = data.message_id;
isItemUnreadInChannel2 = Reflect.apply(isItemUnreadInChannel, moduleValue, [channel_id, message_id]);
r11 = isItemUnreadInChannel2;
if (r11) {
break;
}
readIdToTimestampMap = env0_8.readIdToTimestampMap;
id = value5.id;
readIdToTimestampMap[id] = 0;
break;
}
value8 = value3();
done = value8.done;
if (done) {
break;
}
r3 = value8;
continue;
}
}
}
function CLEAR_ICYMI_READ_STATES() { // fn#74964, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:2890, offset: 0x01d9ea11, size: 19 bytes, params: 1, frame: 2
env0_8.readIdToTimestampMap = {};
}
function value_74956(a0) { // fn#74956, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:1649, offset: 0x01d9e797, size: 186 bytes, params: 2, frame: 14
var object;
var r2;
var readIdToTimestampMap;
var value7;
var value8;
reducibleJoin4: while (true) {
reducibleJoin2: while (true) {
if (a0 == null) {
break reducibleJoin2;
}
readIdToTimestampMap = a0.readIdToTimestampMap;
if (readIdToTimestampMap != null) {
readIdToTimestampMap = a0.readIdToTimestampMap;
object = {readIdToTimestampMap: readIdToTimestampMap};
break reducibleJoin4;
}
break reducibleJoin2;
}
object = {readIdToTimestampMap: {}};
break reducibleJoin4;
}
env1_8 = object;
const Date = global.Date;
const env0_0 = Date.now() - env1_7;
const Object = global.Object;
const value5 = _createForOfIteratorHelperLoose_74951(Object.keys(env1_8.readIdToTimestampMap).filter(_fun74957));
const value6 = value5();
let done = value6.done;
if (!done) {
r2 = value6;
reducibleLoop5: while (true) {
value7 = r2.value;
readIdToTimestampMap = env1_8.readIdToTimestampMap;
delete readIdToTimestampMap[value7];
value8 = value5();
done = value8.done;
if (done) {
break reducibleLoop5;
}
r2 = value8;
continue reducibleLoop5;
}
}
}
function value_74958(a0) { // fn#74958, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:2010, offset: 0x01d9e872, size: 22 bytes, params: 2, frame: 2
return env1_8.readIdToTimestampMap[a0];
}
function _fun74962(a0) { // fn#74962, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:2356, offset: 0x01d9e8b2, size: 86 bytes, params: 2, frame: 5
var r1;
let value = a0 != null;
if (value) {
value = environment.__proto__;
value = env1_8.readIdToTimestampMap[a0.id] == null;
r1 = value || override;
} else {
r1 = value;
}
if (r1) {
value = environment.__proto__;
env1_8.readIdToTimestampMap[a0.id] = a0.timestamp;
}
}
function _fun74957(a0) { // fn#74957, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9764:1844, offset: 0x01d9e851, size: 33 bytes, params: 2, frame: 2
return env2_8.readIdToTimestampMap[a0] < env0_0;
}