Files
2026-07-28 01:06:53 +03:00

529 lines
26 KiB
TypeScript

/* Metro module 12562; source: modules/message_previews/MessagePreviewStore.tsx; dependencies: [57, 6, 7, 15, 17, 18, 1379, 4814, 3, 694, 12563, 4820, 566, 2] */
import Logger from '../debug/Logger.tsx'; /* Metro dependency 3 */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import Dispatcher from '../../Dispatcher.tsx'; /* Metro dependency 694 */
import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */
import MessageStore from '../../stores/MessageStore.tsx'; /* Metro dependency 4814 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
function _fun96119(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#96119, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:6, offset: 0x02155bda, size: 348 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_96122 = 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});
let value = Logger;
value = new value('MessagePreviewStore');
const Store = (Flux).Store;
value = _fun96126(Store);
value = new value();
(FileImportTrackerModule).fileFinishedImporting('modules/message_previews/MessagePreviewStore.tsx');
exports.default = value;
function _createForOfIteratorHelperLoose_96120(a0, a1) { // fn#96120, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:180, offset: 0x02155d36, 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 _fun96121;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_96122(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_96122(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_96122(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun96121;
}
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 _fun96121() { // fn#96121, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:751, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function _isNativeReflectConstruct_96123() { // fn#96123, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1090, offset: 0x02155eaa, 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_96123_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun96126(a0) { // fn#96126, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1338, offset: 0x02155f0c, size: 503 bytes, params: 2, frame: 16
const MessagePreviewStore_961272 = MessagePreviewStore_96127;
Inherits(MessagePreviewStore_961272, a0);
return CreateClass(MessagePreviewStore_961272, [{key: 'initialize', value: function() {
this.waitFor(ChannelStore, MessageStore);
}}, {key: 'isLatest', value: function(a0, a1) {
var value = a0;
var guilds = this.guilds;
var get = guilds.get;
var value2 = null;
var r1 = value2 != value ? value : value2;
value = Reflect.apply(get, guilds, [r1]);
if (value2 == value) {
r1 = undefined;
} else {
value = value.isLatest(a1, this.generation);
r1 = value;
}
return value2 != r1 && r1;
}}, {key: 'isLocalFetchNeeded', value: function(a0) {
var r1;
r1 = this.guilds.get(a0)?.localNeeded;
return r1 == null || r1;
}}, {key: 'message', value: function(a0, a1) {
var r1;
var value = this.guilds.get(a0);
var value2 = null;
if (value2 == value) {
r1 = undefined;
} else {
value = value.messageRecord(a1);
r1 = value;
}
return value2 != r1 ? r1 : value2;
}}, {key: 'data', value: value_96144}, {key: 'handleOneGuildCreate', value: function(a0) {
var value = this.data(a0.id);
value.putMany(a0.lastMessages ?? [], this.generation);
value.putMany(a0.threadMessages ?? [], this.generation);
if (a0.lastMessages != null) {
value.localNeeded = false;
}
}}, {key: 'handleConnectionOpen', value: value_96146}, {key: 'handleGuildCreate', value: function(a0) {
this.handleOneGuildCreate(a0.guild);
}}, {key: 'handleGuildDelete', value: function(a0) {
this.guilds.delete(a0.guild.id);
}}, {key: 'handleMessageCreate', value: function(a0) {
if (a0.optimistic) {
return false;
}
if (a0.isPushNotification) {
return false;
}
var property = this.data;
var guildId = a0.guildId;
var value = null;
value = Reflect.apply(property, this, [value != guildId ? guildId : value]);
value.put(a0.message.channel_id, a0.message, this.generation);
}}, {key: 'handleMessageDelete', value: value_96150}, {key: 'handleMessageUpdate', value: function(a0) {
var property = a0.guildId;
var value = null;
var r3 = value != property ? property : value;
property = a0.message.channel_id;
var id = a0.message.id;
if (value == property) {
return false;
}
if (value == id) {
return false;
}
var value2 = this.data(r3);
var value3 = undefined;
if ((value == value2 ? value3 : value2.messageId(property)) !== id) {
return false;
}
if (value != value2) {
value2.update(a0.message);
}
return value3;
}}, {key: 'handleThreadListSync', value: function(a0) {
var value = this.data(a0.guildId);
value.putMany(a0.mostRecentMessages ?? [], this.generation);
}}, {key: 'handleLoadMessagesSuccess', value: value_96153}, {key: 'handleLocalMessagesLoaded', value: value_96154},
{key: 'handleMessagePreviewsLoaded', value: value_96155}, {key: 'handleMessagePreviewsLocallyLoaded',
value: value_96156}, {key: 'handleLogout', value: function() {
this.guilds.clear();
}}]);
function MessagePreviewStore_96127() { // fn#96127, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1350, offset: 0x02156103, size: 332 bytes, params: 1, frame: 20
var environment;
let value = environment.__proto__;
env1_4(this, MessagePreviewStore_96127);
const items2 = [Dispatcher];
items2[1] = {CONNECTION_OPEN: CONNECTION_OPEN_96128, GUILD_CREATE: GUILD_CREATE_96129,
GUILD_DELETE: GUILD_DELETE_96130, LOAD_MESSAGES_SUCCESS: LOAD_MESSAGES_SUCCESS_96131,
LOCAL_MESSAGES_LOADED: LOCAL_MESSAGES_LOADED_96132, LOGOUT: LOGOUT_96133, MESSAGE_CREATE: MESSAGE_CREATE_96134,
MESSAGE_DELETE: MESSAGE_DELETE_96135, MESSAGE_PREVIEWS_LOADED: MESSAGE_PREVIEWS_LOADED_96136,
MESSAGE_PREVIEWS_LOCALLY_LOADED: MESSAGE_PREVIEWS_LOCALLY_LOADED, MESSAGE_UPDATE: MESSAGE_UPDATE_96138,
THREAD_LIST_SYNC: THREAD_LIST_SYNC_96139};
const value3 = env1_7(MessagePreviewStore_96127);
value = env1_6(this, _isNativeReflectConstruct_96123() ? global.Reflect.construct(value3, items2,
env1_7(this).constructor) : value3.apply(this, items2));
const Map = global.Map;
const value4 = Object.create(Map.prototype, {constructor: {value: Map}});
const map = new Map();
value.guilds = map instanceof Object ? map : value4;
value.generation = 0;
return value;
function MessagePreviewStore_96127CONNECTION_OPEN(a0) { // fn#96128, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1608, owner: MessagePreviewStore_96127.CONNECTION_OPEN, offset: 0x00def9e8, size: 23 bytes, params: 2, frame: 11
return env0_0.handleConnectionOpen(a0);
}
function MessagePreviewStore_96127GUILD_CREATE(a0) { // fn#96129, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1650, owner: MessagePreviewStore_96127.GUILD_CREATE, offset: 0x00defa1c, size: 23 bytes, params: 2, frame: 11
return env0_0.handleGuildCreate(a0);
}
function MessagePreviewStore_96127GUILD_DELETE(a0) { // fn#96130, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1689, owner: MessagePreviewStore_96127.GUILD_DELETE, offset: 0x00e46ef2, size: 23 bytes, params: 2, frame: 11
return env0_0.handleGuildDelete(a0);
}
function MessagePreviewStore_96127LOAD_MESSAGES_SUCCESS(a0) { // fn#96131, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1737, owner: MessagePreviewStore_96127.LOAD_MESSAGES_SUCCESS, offset: 0x0215624f, size: 23 bytes, params: 2, frame: 11
return env0_0.handleLoadMessagesSuccess(a0);
}
function MessagePreviewStore_96127LOCAL_MESSAGES_LOADED(a0) { // fn#96132, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1793, owner: MessagePreviewStore_96127.LOCAL_MESSAGES_LOADED, offset: 0x02156266, size: 25 bytes, params: 2, frame: 11
return env0_0.handleLocalMessagesLoaded(a0);
}
function MessagePreviewStore_96127LOGOUT(a0) { // fn#96133, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1834, owner: MessagePreviewStore_96127.LOGOUT, offset: 0x00e46773, size: 23 bytes, params: 2, frame: 11
return env0_0.handleLogout(a0);
}
function MessagePreviewStore_96127MESSAGE_CREATE(a0) { // fn#96134, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1870, owner: MessagePreviewStore_96127.MESSAGE_CREATE, offset: 0x0215627f, size: 23 bytes, params: 2, frame: 11
return env0_0.handleMessageCreate(a0);
}
function MessagePreviewStore_96127MESSAGE_DELETE(a0) { // fn#96135, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1913, owner: MessagePreviewStore_96127.MESSAGE_DELETE, offset: 0x02156296, size: 23 bytes, params: 2, frame: 11
return env0_0.handleMessageDelete(a0);
}
function MessagePreviewStore_96127MESSAGE_PREVIEWS_LOADED(a0) { // fn#96136, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:1965, owner: MessagePreviewStore_96127.MESSAGE_PREVIEWS_LOADED, offset: 0x021562ad, size: 23 bytes, params: 2, frame: 11
return env0_0.handleMessagePreviewsLoaded(a0);
}
function MESSAGE_PREVIEWS_LOCALLY_LOADED(a0) { // fn#96137, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:2033, owner: MessagePreviewStore_96127.MESSAGE_PREVIEWS_LOCALLY_LOADED, offset: 0x021562c4, size: 25 bytes, params: 2, frame: 11
return env0_0.handleMessagePreviewsLocallyLoaded(a0);
}
function MessagePreviewStore_96127MESSAGE_UPDATE(a0) { // fn#96138, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:2091, owner: MessagePreviewStore_96127.MESSAGE_UPDATE, offset: 0x021562dd, size: 23 bytes, params: 2, frame: 11
return env0_0.handleMessageUpdate(a0);
}
function MessagePreviewStore_96127THREAD_LIST_SYNC(a0) { // fn#96139, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:2136, owner: MessagePreviewStore_96127.THREAD_LIST_SYNC, offset: 0x021562f4, size: 23 bytes, params: 2, frame: 11
return env0_0.handleThreadListSync(a0);
}
}
function value_96144(a0) { // fn#96144, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:2720, offset: 0x021563cb, size: 111 bytes, params: 2, frame: 16
var set;
var value;
let guilds = this.guilds;
if (!guilds.has(a0)) {
guilds = this.guilds;
set = guilds.set;
value = environment.__proto__;
Reflect.apply(set, guilds, [a0, new (require(12563) /* metro dependency 12563: PreviewData */).PreviewData()]);
}
return this.guilds.get(a0);
}
function value_96146({guilds}) { // fn#96146, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:3091, offset: 0x021564a7, size: 90 bytes, params: 2, frame: 14
var r2;
var value3;
var value4;
this.generation = this.generation + 1;
let value = environment.__proto__;
value = _createForOfIteratorHelperLoose_96120(guilds);
const value2 = value();
let done = value2.done;
if (!done) {
for (r2 = value2; true; r2 = value4) {
value3 = r2.value;
this.handleOneGuildCreate(value3);
value4 = value();
done = value4.done;
if (done) {
break;
}
}
}
}
function value_96150(a0) { // fn#96150, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:3617, offset: 0x0215659c, size: 181 bytes, params: 2, frame: 19
var r5;
var value5;
var messageStoreBinding;
var value6;
const guildId = a0.guildId;
let value = null;
const r4 = value != guildId ? guildId : value;
const value2 = this.data(r4);
const value3 = undefined;
if ((value == value2 ? value3 : value2.messageId(a0.channelId)) === a0.id) {
value5 = environment.__proto__;
messageStoreBinding = MessageStore;
value6 = messageStoreBinding.getMessages(a0.channelId);
r5 = value6.hasMoreAfter ? value : value6.last();
if (value != r5) {
value = this.data(r4);
value.put(a0.channelId, r5, this.generation);
} else {
this.data(r4).delete(a0.channelId);
}
}
return value3;
}
function value_96153(a0) { // fn#96153, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:4310, offset: 0x02156702, size: 238 bytes, params: 2, frame: 21
var put;
var property;
var putNew;
let value = environment.__proto__;
const channelStoreBinding = ChannelStore;
const getBasicChannel = channelStoreBinding.getBasicChannel;
let channelId = a0.channelId;
const value2 = Reflect.apply(getBasicChannel, channelStoreBinding, [channelId]);
const value3 = null;
if (value3 == value2) {
return false;
}
value = require(4820) /* metro dependency 4820: requireSortedDescending */;
value.requireSortedDescending(a0.messages);
if (a0.isAfter) {
value = this.data(value2.guild_id);
putNew = value.putNew;
channelId = a0.channelId;
property = a0.messages[0];
Reflect.apply(putNew, value, [channelId, value3 != property ? property : value3, this.generation]);
} else if (a0.isBefore) {
value = this.data(value2.guild_id);
putNew = value.putNew;
channelId = a0.channelId;
property = a0.messages[0];
Reflect.apply(putNew, value, [channelId, value3 != property ? property : value3, this.generation]);
} else if (a0.hasMoreAfter) {
value = this.data(value2.guild_id);
putNew = value.putNew;
channelId = a0.channelId;
property = a0.messages[0];
Reflect.apply(putNew, value, [channelId, value3 != property ? property : value3, this.generation]);
} else {
value = this.data(value2.guild_id);
put = value.put;
channelId = a0.channelId;
property = a0.messages[0];
Reflect.apply(put, value, [channelId, value3 != property ? property : value3, this.generation]);
}
}
function value_96154(a0) { // fn#96154, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:4685, offset: 0x021567f0, size: 145 bytes, params: 2, frame: 17
var requireSortedDescending;
var messages;
var putNew;
var property;
let value = environment.__proto__;
const channelStoreBinding = ChannelStore;
const getBasicChannel = channelStoreBinding.getBasicChannel;
let channelId = a0.channelId;
const value2 = Reflect.apply(getBasicChannel, channelStoreBinding, [channelId]);
const value3 = null;
if (value3 != value2) {
value = require(4820) /* metro dependency 4820: requireSortedDescending */;
requireSortedDescending = value.requireSortedDescending;
messages = a0.messages;
Reflect.apply(requireSortedDescending, value, [messages]);
value = this.data(value2.guild_id);
putNew = value.putNew;
channelId = a0.channelId;
messages = a0.messages;
property = messages[0];
Reflect.apply(putNew, value, [channelId, value3 != property ? property : value3, -Infinity]);
}
}
function value_96155(a0) { // fn#96155, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:4911, offset: 0x02156881, size: 191 bytes, params: 2, frame: 22
var r2;
var value4;
var isLatest;
var channel_id;
var generation;
var put;
var value5;
let value = environment.__proto__;
const binding = env1_11;
binding.verbose('adding remote previews (guildId: ' + a0.guildId + ', messages: ' + a0.messages.length + ')');
const value2 = this.data(a0.guildId);
value = _createForOfIteratorHelperLoose_96120(a0.messages);
const value3 = value();
let done = value3.done;
if (!done) {
r2 = value3;
while (true) {
value4 = r2.value;
isLatest = value2.isLatest;
channel_id = value4.channel_id;
generation = this.generation;
if (!Reflect.apply(isLatest, value2, [channel_id, generation])) {
put = value2.put;
channel_id = value4.channel_id;
generation = this.generation;
Reflect.apply(put, value2, [channel_id, value4, generation]);
}
value5 = value();
done = value5.done;
if (done) {
break;
}
r2 = value5;
continue;
}
}
}
function value_96156(a0) { // fn#96156, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12752:5255, offset: 0x02156940, size: 211 bytes, params: 2, frame: 23
var r3;
var value5;
var value6;
var property;
var property2;
var has;
var value7;
const binding = env1_11;
binding.verbose('adding local previews (guildId: ' + a0.guildId + ', messages: ' + a0.messages.length + ')');
const value2 = this.data(a0.guildId);
const value3 = _createForOfIteratorHelperLoose_96120(a0.messages);
const value4 = value3();
let done = value4.done;
if (!done) {
r3 = value4;
while (true) {
value5 = r3.value;
value6 = env1_3(value5, 2);
property = value6[0];
property2 = value6[1];
has = value2.has;
if (!Reflect.apply(has, value2, [property])) {
value2.put(property, property2, -Infinity);
}
value7 = value3();
done = value7.done;
if (done) {
break;
}
r3 = value7;
continue;
}
}
value2.localNeeded = false;
}
}
}
global.__d(_fun96119, 12562, [57, 6, 7, 15, 17, 18, 1379, 4814, 3, 694, 12563, 4820, 566,
2]) /* metro module 12562, dependencies: [57, 6, 7, 15, 17, 18, 1379, 4814, 3, 694, 12563, 4820, 566, 2] */;