254 lines
13 KiB
TypeScript
254 lines
13 KiB
TypeScript
/* Metro module 4644; source: stores/UploadAttachmentStore.tsx; dependencies: [6, 7, 15, 17, 18, 4645, 661, 4647, 1244, 22, 4648, 4658, 566, 694, 2] */
|
|
function _fun39942(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#39942, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:6, offset: 0x010f0e4c, size: 466 bytes, params: 8, frame: 20
|
|
let env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_4 = importDefault(7) /* metro dependency 7 */;
|
|
const env0_5 = importDefault(15) /* metro dependency 15 */;
|
|
const env0_6 = importDefault(17) /* metro dependency 17 */;
|
|
const env0_7 = importDefault(18) /* metro dependency 18 */;
|
|
const env0_8 = (require(4645) /* metro dependency 4645: DraftStore */).DraftType;
|
|
const env0_9 = (require(661) /* metro dependency 661: Constants */).MAX_UPLOAD_COUNT;
|
|
const Map = global.Map;
|
|
let map = new Map();
|
|
const env0_11 = [];
|
|
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
|
|
_fun39949(Store).displayName = 'UploadAttachmentStore';
|
|
map = new map(importDefault(694) /* metro dependency 694: Dispatcher */,
|
|
{UPLOAD_ATTACHMENT_POP_FILE: function({channelId}) {
|
|
var r6;
|
|
var value2 = _getUploads(channelId, DraftType.ChannelMessage);
|
|
var items = [];
|
|
arraySpread(items, value2, 0, r6);
|
|
items.shift();
|
|
setUploads(channelId, DraftType.ChannelMessage, items);
|
|
}, UPLOAD_ATTACHMENT_ADD_FILES: UPLOAD_ATTACHMENT_ADD_FILES,
|
|
UPLOAD_ATTACHMENT_UPDATE_FILE: UPLOAD_ATTACHMENT_UPDATE_FILE,
|
|
UPLOAD_ATTACHMENT_REMOVE_FILE: function({channelId, id, draftType}) {
|
|
var r8;
|
|
var value2 = _getUploads(channelId, draftType);
|
|
var items = [];
|
|
arraySpread(items, value2, 0, r8);
|
|
var index = items.findIndex(_fun39964);
|
|
if (index > -1) {
|
|
items.splice(index, 1)[0].removeFromMsgDraft();
|
|
setUploads(channelId, draftType, items);
|
|
}
|
|
}, UPLOAD_ATTACHMENT_REMOVE_FILES: function({channelId, attachmentIds, draftType}) {
|
|
var r8;
|
|
var value2 = _getUploads(channelId, draftType);
|
|
var items = [];
|
|
arraySpread(items, value2, 0, r8);
|
|
var env0_0 = items;
|
|
attachmentIds.forEach(_fun39966);
|
|
setUploads(channelId, draftType, items);
|
|
}, UPLOAD_ATTACHMENT_CLEAR_ALL_FILES: function({channelId, draftType}) {
|
|
setUploads(channelId, draftType, []);
|
|
}, UPLOAD_ATTACHMENT_SET_UPLOADS: function({channelId, uploads, draftType}) {
|
|
setUploads(channelId, draftType, uploads);
|
|
}, UPLOAD_ATTACHMENT_SET_FILE: UPLOAD_ATTACHMENT_SET_FILE});
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('stores/UploadAttachmentStore.tsx');
|
|
exports.default = map;
|
|
}
|
|
|
|
function _isNativeReflectConstruct_39943() { // fn#39943, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:195, offset: 0x010f101e, size: 94 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_39943_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function _getUploads(a0, a1) { // fn#39946, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:407, offset: 0x010f107c, size: 49 bytes, params: 3, frame: 14
|
|
const getChannelUploadsBinding = getChannelUploads;
|
|
const value2 = undefined;
|
|
const channelUploadsBinding = getChannelUploadsBinding(a0);
|
|
let r0 = channelUploadsBinding == null ? value2 : channelUploadsBinding.get(a1);
|
|
r0 = r0 ?? env0_11;
|
|
return r0;
|
|
}
|
|
|
|
function getChannelUploads(a0) { // fn#39947, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:509, offset: 0x010f10ad, size: 56 bytes, params: 2, frame: 11
|
|
return env0_10.get(a0) ?? new global.Map();
|
|
}
|
|
|
|
function setUploads(a0, a1, a2) { // fn#39948, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:581, offset: 0x010f10e5, size: 51 bytes, params: 4, frame: 16
|
|
const channelUploads = getChannelUploads(a0);
|
|
channelUploads.set(a1, a2);
|
|
env0_10.set(a0, channelUploads);
|
|
}
|
|
|
|
function _fun39949(a0) { // fn#39949, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:663, offset: 0x010f1118, size: 187 bytes, params: 2, frame: 16
|
|
const closure = UploadAttachmentStore;
|
|
env0_7(closure, a0);
|
|
return env0_4(closure, [{key: 'getFirstUpload', value: value_39951}, {key: 'hasAdditionalUploads',
|
|
value: value_39952}, {key: 'getUploads', value: function(a0, a1) {
|
|
return _getUploads(a0, a1);
|
|
}}, {key: 'getUploadCount', value: value_39954}, {key: 'getUpload', value: value_39955}, {key: 'findUpload',
|
|
value: value_39957}]);
|
|
}
|
|
|
|
function UPLOAD_ATTACHMENT_ADD_FILES({files, channelId, draftType, allowOptimization}) { // fn#39959, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:1750, offset: 0x010f1310, size: 319 bytes, params: 2, frame: 21
|
|
var defaultImport2;
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const value2 = _getUploads(channelId, draftType);
|
|
const items = [];
|
|
arraySpread(items, value2, 0, undefined);
|
|
if (items.length + files.length > MAX_UPLOAD_COUNT) {
|
|
if (draftType === DraftType.SlashCommand) {
|
|
(importDefault(22) /* metro dependency 22 */).forEach(files, _fun39960);
|
|
setUploads(channelId, draftType, items);
|
|
} else if (draftType !== DraftType.ApplicationLauncherCommand) {
|
|
defaultImport2 = importDefault(4647) /* metro dependency 4647: AlertActionCreators */;
|
|
defaultImport2.show({title: intl.string(t.wOr6hB), body: intl.formatToPlainString(t['qqyp/e'],
|
|
{limit: MAX_UPLOAD_COUNT})});
|
|
} else {
|
|
(importDefault(22) /* metro dependency 22 */).forEach(files, _fun39960);
|
|
setUploads(channelId, draftType, items);
|
|
}
|
|
} else {
|
|
(importDefault(22) /* metro dependency 22 */).forEach(files, _fun39960);
|
|
setUploads(channelId, draftType, items);
|
|
}
|
|
}
|
|
|
|
function UPLOAD_ATTACHMENT_UPDATE_FILE({channelId, id, filename, description, spoiler, thumbnail, draftType}) { // fn#39961, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2174, offset: 0x010f14a5, size: 120 bytes, params: 2, frame: 18
|
|
const setUploadsBinding = setUploads;
|
|
const value = _getUploads(channelId, draftType);
|
|
const items2 = [];
|
|
arraySpread(items2, value, 0, undefined);
|
|
setUploadsBinding(channelId, draftType, items2.map(function(a0) {
|
|
if (a0.id === id) {
|
|
if (filename !== undefined) {
|
|
a0.filename = filename;
|
|
}
|
|
if (spoiler !== undefined) {
|
|
a0.spoiler = spoiler;
|
|
}
|
|
if (description !== undefined) {
|
|
a0.description = description;
|
|
}
|
|
if (thumbnail !== undefined) {
|
|
a0.isThumbnail = thumbnail;
|
|
}
|
|
}
|
|
return a0;
|
|
}));
|
|
}
|
|
|
|
function UPLOAD_ATTACHMENT_REMOVE_FILE({channelId, id, draftType}) { // fn#39963, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2486, offset: 0x010f157c, size: 123 bytes, params: 2, frame: 19
|
|
const value2 = _getUploads(channelId, draftType);
|
|
const items2 = [];
|
|
arraySpread(items2, value2, 0, undefined);
|
|
const index = items2.findIndex(_fun39964);
|
|
if (index > -1) {
|
|
items2.splice(index, 1)[0].removeFromMsgDraft();
|
|
setUploads(channelId, draftType, items2);
|
|
}
|
|
}
|
|
|
|
function UPLOAD_ATTACHMENT_REMOVE_FILES({channelId, attachmentIds, draftType}) { // fn#39965, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2740, offset: 0x010f1633, size: 82 bytes, params: 2, frame: 19
|
|
const value2 = _getUploads(channelId, draftType);
|
|
const items2 = [];
|
|
arraySpread(items2, value2, 0, undefined);
|
|
attachmentIds.forEach(_fun39966);
|
|
setUploads(channelId, draftType, items2);
|
|
}
|
|
|
|
function UPLOAD_ATTACHMENT_SET_FILE({channelId, id, file, draftType, allowOptimization}) { // fn#39970, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:3201, offset: 0x010f1735, size: 157 bytes, params: 2, frame: 21
|
|
const value2 = _getUploads(channelId, draftType);
|
|
const items2 = [];
|
|
arraySpread(items2, value2, 0, allowOptimization);
|
|
const value3 = items2.filter(function({id}) {
|
|
return id !== id;
|
|
});
|
|
const CloudUpload = (require(4648) /* metro dependency 4648: CloudUpload */).CloudUpload;
|
|
const value4 = Object.create(CloudUpload.prototype, {constructor: {value: CloudUpload}});
|
|
const cloudUpload = new CloudUpload(file, channelId, undefined, allowOptimization);
|
|
value3.push(cloudUpload instanceof Object ? cloudUpload : value4);
|
|
setUploads(channelId, draftType, value3);
|
|
}
|
|
|
|
function value_39951(a0, a1) { // fn#39951, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:1002, offset: 0x010f11d3, size: 43 bytes, params: 3, frame: 13
|
|
let value = environment.__proto__;
|
|
value = _getUploads(a0, a1);
|
|
return value.length > 0 ? value[0] : null;
|
|
}
|
|
|
|
function value_39952(a0, a1) { // fn#39952, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:1103, offset: 0x010f11fe, size: 49 bytes, params: 3, frame: 13
|
|
const value = environment.__proto__;
|
|
return (_getUploads(a0, a1).length ?? 0) > 1;
|
|
}
|
|
|
|
function value_39954(a0, a1) { // fn#39954, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:1265, offset: 0x010f1246, size: 42 bytes, params: 3, frame: 13
|
|
const value = environment.__proto__;
|
|
return _getUploads(a0, a1).length ?? 0;
|
|
}
|
|
|
|
function value_39955(a0, a1, a2) { // fn#39955, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:1355, offset: 0x010f1270, size: 48 bytes, params: 4, frame: 14
|
|
var environment;
|
|
const env0_0 = a1;
|
|
const value = environment.__proto__;
|
|
return _getUploads(a0, a2).find(function({id}) {
|
|
return id === require;
|
|
});
|
|
}
|
|
|
|
function value_39957(a0, a1, a2) { // fn#39957, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:1441, offset: 0x010f12a0, size: 37 bytes, params: 4, frame: 13
|
|
const value = environment.__proto__;
|
|
return _getUploads(a0, a1).find(a2);
|
|
}
|
|
|
|
function _fun39960(a0) { // fn#39960, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2059, offset: 0x010f144f, size: 86 bytes, params: 2, frame: 19
|
|
const value = environment.__proto__;
|
|
const CloudUpload = (require(4648) /* metro dependency 4648: CloudUpload */).CloudUpload;
|
|
const channelIdBinding = channelId;
|
|
const binding = env0_2;
|
|
binding.push(new CloudUpload(a0, channelIdBinding, binding.length, allowOptimization));
|
|
}
|
|
|
|
function _fun39964(a0) { // fn#39964, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2587, offset: 0x010f15f7, size: 60 bytes, params: 2, frame: 14
|
|
let value = environment.__proto__;
|
|
value = require(4658) /* metro dependency 4658: UploadUtils */;
|
|
const doesImageMatchUpload = value.doesImageMatchUpload;
|
|
const idBinding = id;
|
|
return Reflect.apply(doesImageMatchUpload, value, [{uri: idBinding, filename: idBinding}, a0]);
|
|
}
|
|
|
|
function _fun39966(a0) { // fn#39966, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2849, offset: 0x010f1685, size: 81 bytes, params: 2, frame: 13
|
|
const env0_0 = a0;
|
|
const index = env0_0.findIndex(_fun39967);
|
|
if (index > -1) {
|
|
env0_0.splice(index, 1)[0].removeFromMsgDraft();
|
|
}
|
|
}
|
|
|
|
function _fun39967({id}) { // fn#39967, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4822:2872, offset: 0x010f16d6, size: 21 bytes, params: 2, frame: 2
|
|
return env0_0 === id;
|
|
}
|
|
|