Files
discord-decomp/sources/modules/device/native/DeviceMedia.tsx
T
2026-07-28 01:06:53 +03:00

183 lines
11 KiB
TypeScript

/* Metro module 11104; source: modules/device/native/DeviceMedia.tsx; dependencies: [661, 629, 683, 690, 11105, 477, 2] */
import AnalyticsUtils from '../../../utils/AnalyticsUtils.tsx'; /* Metro dependency 683 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as ReactBatchUpdatesNativeModule from '../../../external/discord_common/js/shared/utils/ReactBatchUpdates.native.tsx'; /* Metro dependency 690 */
function _fun85055(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#85055, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:6, offset: 0x01f62228, size: 200 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_4 = (require(629) /* metro dependency 629 */).create(function() {
return {'assets': null, 'page': 0, 'hasReachedEnd': false, 'lastAssetIndex': 0};
});
object = {getNextAssetPage: getNextAssetPage, refreshAssets: refreshAssets, useAssets: useAssets,
useHasReachedEnd: useHasReachedEnd};
(FileImportTrackerModule).fileFinishedImporting('modules/device/native/DeviceMedia.tsx');
exports.default = object;
function getNextAssetPage({batchSize, extensions}) { // fn#85057, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:226, offset: 0x01f62300, size: 276 bytes, params: 2, frame: 22
var image;
var property;
var moduleValue;
var env0_2;
const {assets, page, lastAssetIndex, hasReachedEnd, endCursor} = env0_4.getState();
if (assets != null) {
if (!hasReachedEnd) {
property = assets.edges[assets.edges.length - 1];
image = property == null || property.node == null ? undefined : property.node.image;
moduleValue = require(477) /* metro dependency 477: PlatformUtils */;
if (moduleValue.isIOS()) {
if (image != null) {
if (image.uri != null) {
env0_2 = page + 1;
(importDefault(11105) /* metro dependency 11105: getDeviceMediaPhotos */)({batchSize: batchSize,
endCursor: endCursor, lastAssetIndex: lastAssetIndex, lastNodeImageUri: image.uri,
extensions: extensions,
onFetched: function(a0) {
_fun85059(a0);
}});
}
}
} else {
env0_2 = page + 1;
(importDefault(11105) /* metro dependency 11105: getDeviceMediaPhotos */)({batchSize: batchSize,
endCursor: endCursor, lastAssetIndex: lastAssetIndex, lastNodeImageUri: image.uri,
extensions: extensions,
onFetched: onFetched});
}
}
}
function getNextAssetPageOnFetched(a0) { // fn#85058, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:612, owner: getNextAssetPage.onFetched, offset: 0x01f62414, size: 21 bytes, params: 2, frame: 11
onFetchedApplyStateUpdate(a0);
function onFetchedApplyStateUpdate(a0) { // fn#85059, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:615, owner: getNextAssetPage.onFetched.applyStateUpdate, offset: 0x01f62429, size: 342 bytes, params: 2, frame: 21
var length;
var r7;
var edges;
var value4;
var unshift;
var items2;
const env0_0 = a0;
const lastAssetIndexBinding = lastAssetIndex;
const value2 = undefined;
if (a0 == null) {
length = value2;
} else {
edges = a0.edges;
length = edges == null ? value2 : edges.length;
}
const value3 = 0;
let r1 = length ?? value3;
const env0_1 = lastAssetIndexBinding + r1;
if (assets != null) {
value4 = a0 == null;
if (value4) {
r1 = value4;
r7 = value2;
} else {
edges = a0.edges;
r1 = edges == null;
r7 = edges;
}
if (!r1) {
unshift = r7.unshift;
edges = assets.edges;
items2 = [];
arraySpread(items2, edges, value3, undefined);
apply(unshift, items2, r7, undefined);
}
}
(require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun85060);
let r5 = a0 == null || value3 === a0.edges.length;
r5 = !r5 ? (a0.page_info == null ? value2 : a0.page_info.has_next_page) === false : r5;
if (r5) {
(require(690) /* metro dependency 690: ReactBatchUpdatesNative */).batchUpdates(_fun85061);
}
const defaultImport = AnalyticsUtils;
const track = defaultImport.track;
const MEDIA_PICKER_INFINITE_SCROLL_PAGED = AnalyticEvents.MEDIA_PICKER_INFINITE_SCROLL_PAGED;
Reflect.apply(track, defaultImport, [MEDIA_PICKER_INFINITE_SCROLL_PAGED, {page: env1_2, has_reached_end: r5}]);
return value2;
function _fun85060() { // fn#85060, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:802, offset: 0x01f6257f, size: 98 bytes, params: 1, frame: 16
const binding = env3_4;
const setState = binding.setState;
const binding2 = env0_0;
const value3 = undefined;
Reflect.apply(setState, binding, [{assets: binding2, page: env2_2, lastAssetIndex: env0_1,
endCursor: binding2 == null || env0_0.page_info == null ? value3 : env0_0.page_info.end_cursor}]);
return value3;
}
function _fun85061() { // fn#85061, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1036, offset: 0x01f625e1, size: 34 bytes, params: 1, frame: 12
return env3_4.setState({hasReachedEnd: env0_2});
}
}
}
}
function refreshAssets({batchSize, extensions}) { // fn#85062, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1174, offset: 0x01f62603, size: 77 bytes, params: 2, frame: 14
(importDefault(11105) /* metro dependency 11105: getDeviceMediaPhotos */)({batchSize: batchSize,
extensions: extensions, onFetched: function(a0) {
_fun85064(a0);
}});
function refreshAssetsOnFetched(a0) { // fn#85063, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1269, owner: refreshAssets.onFetched, offset: 0x01f62650, size: 21 bytes, params: 2, frame: 11
onFetchedApplyStateUpdate_85064(a0);
function onFetchedApplyStateUpdate_85064(a0) { // fn#85064, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1272, owner: refreshAssets.onFetched.applyStateUpdate, offset: 0x01f62665, size: 210 bytes, params: 2, frame: 19
var environment;
var value3;
var defaultImport;
const env0_0 = a0;
let value = undefined;
const length = a0 == null ? value : a0.edges.filter(function(a0) {
var value = undefined;
return (a0 == null || a0.node == null || a0.node.image == null ? value : a0.node.image.uri) == null || (a0 == null || a0.node == null || a0.node.image == null ? value : a0.node.image.uri) === '';
}).length;
const value2 = 0;
const r6 = length ?? value2;
if (r6 > value2) {
value3 = environment.__proto__.__proto__;
defaultImport = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
defaultImport.track(AnalyticEvents.MEDIA_PICKER_ASSETS_DEBUG, {num_broken_assets: r6,
num_assets: a0 == null || a0.edges == null ? value : a0.edges.length,
location: 'DeviceMedia.applyStateUpdate'});
}
(ReactBatchUpdatesNativeModule).batchUpdates(_fun85066);
return value;
function _fun85066() { // fn#85066, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1703, offset: 0x01f627a5, size: 152 bytes, params: 1, frame: 17
const value = environment.__proto__.__proto__.__proto__;
const binding = env3_4;
const setState = binding.setState;
const binding2 = env0_0;
const value3 = undefined;
const has_next_page = env0_0 == null || env0_0.page_info == null ? value3 : env0_0.page_info.has_next_page;
Reflect.apply(setState, binding, [{assets: binding2, page: 0, lastAssetIndex: batchSize,
endCursor: binding2 == null || env0_0.page_info == null ? value3 : env0_0.page_info.end_cursor,
hasReachedEnd: !(has_next_page == null || has_next_page)}]);
return value3;
}
}
}
}
function useAssets() { // fn#85067, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1930, offset: 0x01f6283d, size: 25 bytes, params: 1, frame: 11
return env0_4(function(a0) {
return a0.assets;
});
}
function useHasReachedEnd() { // fn#85069, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11290:1968, offset: 0x01f62861, size: 25 bytes, params: 1, frame: 11
return env0_4(function(a0) {
return a0.hasReachedEnd;
});
}
}
global.__d(_fun85055, 11104, [661, 629, 683, 690, 11105, 477,
2]) /* metro module 11104, dependencies: [661, 629, 683, 690, 11105, 477, 2] */;