decord/alpha/source/modules/device/native/DeviceMedia.tsx

213 lines
7 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 10004
// Function ID: 10005
// Name: DeviceMedia
2026-10-09 10:00:15 +00:00
// Dependencies: [1085, 570, 1265, 1272, 10005, 1382, 2]
2026-07-20 16:05:17 +00:00
2026-10-09 10:00:15 +00:00
// Module 10004 (DeviceMedia)
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
2026-10-09 10:00:15 +00:00
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1265 */;
import getDeviceMediaPhotosDefault from "getDeviceMediaPhotos" /* 10005 */;
2026-10-03 08:58:59 +00:00
import module_570 from "module_570" /* 570 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let dependencyMap, page;
2026-07-20 16:05:17 +00:00
2026-10-03 08:58:59 +00:00
const AnalyticEvents = Constants.AnalyticEvents;
let state = module_570.create(() => ({ assets: null, page: 0, hasReachedEnd: false, lastAssetIndex: 0 }));
let obj = {
2026-07-20 16:05:17 +00:00
getNextAssetPage(arg0) {
2026-10-03 08:58:59 +00:00
let batchSize;
let extensions;
let tmp2;
2026-08-24 06:08:38 +00:00
dependencyMap = undefined;
2026-07-20 16:05:17 +00:00
({ batchSize, extensions } = arg0);
2026-07-23 10:11:24 +00:00
state = state.getState();
let assets = state.assets;
let lastAssetIndex = state.lastAssetIndex;
2026-07-20 16:05:17 +00:00
if (null != assets) {
if (!state.hasReachedEnd) {
2026-10-03 08:58:59 +00:00
let image;
let num = 1;
2026-07-29 08:29:29 +00:00
if (assets.edges[assets.edges.length - 1] != null) {
2026-07-20 16:05:17 +00:00
const node = tmp4.node;
2026-07-29 08:29:29 +00:00
if (node != null) {
2026-10-03 08:58:59 +00:00
image = node.image;
2026-07-20 16:05:17 +00:00
}
}
2026-10-09 10:00:15 +00:00
let obj = assets(1382);
2026-07-20 16:05:17 +00:00
if (!obj.isIOS()) {
2026-07-23 10:11:24 +00:00
dependencyMap = tmp2 + 1;
2026-10-03 08:58:59 +00:00
let obj2 = {
batchSize,
endCursor: tmp3,
lastAssetIndex,
lastNodeImageUri: image.uri,
extensions,
onFetched(edges) {
2026-10-03 08:58:59 +00:00
let closure_2;
assets = edges;
let num;
2026-10-03 08:58:59 +00:00
const tmp2 = lastAssetIndex;
if (edges != null) {
edges = edges.edges;
if (edges != null) {
num = edges.length;
}
}
if (num == null) {
num = 0;
}
2026-10-03 08:58:59 +00:00
lastAssetIndex = tmp2 + num;
if (null != assets) {
if (edges != null) {
const edges1 = edges.edges;
if (edges1 != null) {
const unshift = edges1.unshift;
const items = [];
2026-10-03 08:58:59 +00:00
HermesBuiltin.arraySpread(items, tmp3.edges, 0);
HermesBuiltin.apply(unshift, items, edges1);
}
}
}
2026-10-03 08:58:59 +00:00
let obj = assets(page[3]);
obj.batchUpdates(() => {
let end_cursor;
2026-10-03 08:58:59 +00:00
const obj = { assets, page, lastAssetIndex, endCursor: end_cursor };
end_cursor = undefined;
const setState = state.setState;
if (assets != null) {
const page_info = assets.page_info;
if (page_info != null) {
end_cursor = page_info.end_cursor;
}
}
2026-10-03 08:58:59 +00:00
setState(obj);
});
2026-10-03 08:58:59 +00:00
let tmp13 = null == edges;
const tmp10 = assets;
if (!tmp13) {
tmp13 = 0 === edges.edges.length;
}
2026-10-03 08:58:59 +00:00
if (!tmp13) {
let page_info = edges.page_info;
let has_next_page;
if (page_info != null) {
has_next_page = page_info.has_next_page;
}
2026-10-03 08:58:59 +00:00
tmp13 = false === has_next_page;
}
2026-10-03 08:58:59 +00:00
page = tmp13;
if (page) {
const tmp10Result = tmp10(page[3]);
tmp10Result.batchUpdates(() => {
const obj = { hasReachedEnd };
return state.setState(obj);
});
}
2026-10-03 08:58:59 +00:00
const obj2 = { page, has_reached_end: tmp13 };
const obj3 = lastAssetIndex(page[2]);
obj3.track(constants.MEDIA_PICKER_INFINITE_SCROLL_PAGED, obj2);
}
2026-07-20 16:05:17 +00:00
};
2026-10-09 10:00:15 +00:00
lastAssetIndex(10005)(obj2);
2026-07-20 16:05:17 +00:00
}
}
}
},
refreshAssets(batchSize) {
batchSize = batchSize.batchSize;
2026-10-03 08:58:59 +00:00
let obj = {
2026-07-20 16:05:17 +00:00
batchSize,
extensions: batchSize.extensions,
onFetched(edges) {
2026-10-03 08:58:59 +00:00
let length;
const assets = edges;
2026-07-29 08:29:29 +00:00
let num;
if (edges != null) {
edges = edges.edges;
num = edges.filter((node) => {
let uri;
if (node != null) {
node = node.node;
if (node != null) {
const image = node.image;
if (image != null) {
uri = image.uri;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
}
let tmp2 = null == uri;
if (!tmp2) {
let uri1;
if (node != null) {
const node2 = node.node;
if (node2 != null) {
const image2 = node2.image;
if (image2 != null) {
uri1 = image2.uri;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
tmp2 = "" === uri1;
}
return tmp2;
}).length;
}
if (num == null) {
num = 0;
}
if (num > 0) {
2026-10-03 08:58:59 +00:00
let tmp2 = dependencyMap;
let obj = { num_broken_assets: num, num_assets: length, location: "DeviceMedia.applyStateUpdate" };
length = undefined;
const track = AnalyticsUtilsDefault.track;
const MEDIA_PICKER_ASSETS_DEBUG = constants.MEDIA_PICKER_ASSETS_DEBUG;
AnalyticsUtilsDefault;
2026-07-29 08:29:29 +00:00
if (edges != null) {
const edges1 = edges.edges;
if (edges1 != null) {
length = edges1.length;
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
track(MEDIA_PICKER_ASSETS_DEBUG, obj);
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
const obj2 = batchSize(dependencyMap[3]);
obj2.batchUpdates(() => {
2026-07-29 08:29:29 +00:00
let end_cursor;
2026-10-03 08:58:59 +00:00
let num;
const obj = { assets, page: 0, lastAssetIndex: batchSize, endCursor: end_cursor, hasReachedEnd: !num };
end_cursor = undefined;
setState = setState.setState;
if (assets != null) {
2026-07-29 08:29:29 +00:00
const page_info = tmp2.page_info;
if (page_info != null) {
end_cursor = page_info.end_cursor;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
num = undefined;
if (assets != null) {
2026-07-29 08:29:29 +00:00
const page_info2 = tmp2.page_info;
if (page_info2 != null) {
num = page_info2.has_next_page;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
if (num == null) {
num = 1;
}
2026-10-03 08:58:59 +00:00
setState(obj);
2026-07-29 08:29:29 +00:00
});
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
};
const tmp = getDeviceMediaPhotosDefault(obj);
2026-07-20 16:05:17 +00:00
},
useAssets() {
return state((assets) => assets.assets);
},
useHasReachedEnd() {
return state((hasReachedEnd) => hasReachedEnd.hasReachedEnd);
}
};
2026-10-03 08:58:59 +00:00
const result = size.fileFinishedImporting("modules/device/native/DeviceMedia.tsx");
export default obj;