decord/source/modules/media_viewer/native/useMediaViewerSources.tsx

55 lines
1.7 KiB
TypeScript
Raw Normal View History

// Module ID: 8288
// Function ID: 8289
// Name: useMediaViewerSources
// Dependencies: [4443, 2]
// Exports: removeSpoiler, setMediaViewerSources, toggleSpoiler, updateMediaViewerSources
2026-07-20 16:05:17 +00:00
// Module 8288 (useMediaViewerSources)
import ZustandStore from "ZustandStore" /* 4443 */;
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
const zustandStore = ZustandStore.createZustandStore(() => {
const obj = { sources: [], userRevealedIndexes: new Set() };
2026-07-20 16:05:17 +00:00
return obj;
});
const result = size.fileFinishedImporting("modules/media_viewer/native/useMediaViewerSources.tsx");
2026-07-20 16:05:17 +00:00
export const MediaViewerSourcesStore = zustandStore;
export const setMediaViewerSources = function setMediaViewerSources(sources) {
let initialIndex = sources.initialIndex;
2026-07-20 16:05:17 +00:00
if (initialIndex === undefined) {
initialIndex = null;
}
if (null != initialIndex) {
const _Set2 = Set;
const items = [initialIndex];
let set = new Set(items);
} else {
const _Set = Set;
set = new Set();
}
zustandStore.setState({ sources: sources.sources, userRevealedIndexes: set });
};
export const updateMediaViewerSources = function updateMediaViewerSources(items) {
zustandStore.setState({ sources: items });
2026-07-20 16:05:17 +00:00
};
export const removeSpoiler = function removeSpoiler(index) {
const field = zustandStore.getField("userRevealedIndexes");
if (!field.has(index)) {
2026-07-20 16:05:17 +00:00
const _Set = Set;
const set = new Set(field);
set.add(index);
const obj2 = { userRevealedIndexes: set };
zustandStore.setState(obj2);
2026-07-20 16:05:17 +00:00
}
};
export const toggleSpoiler = function toggleSpoiler(index) {
const set = new Set(zustandStore.getField("userRevealedIndexes"));
2026-07-20 16:05:17 +00:00
if (set.has(index)) {
set.delete(index);
} else {
set.add(index);
}
zustandStore.setState({ userRevealedIndexes: set });
2026-07-20 16:05:17 +00:00
};