@pitcher/canvas-ui 2026.1.20-102040-beta → 2026.1.20-113923-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas-ui.js +51 -0
- package/canvas-ui.js.map +1 -1
- package/package.json +1 -1
package/canvas-ui.js
CHANGED
|
@@ -110485,9 +110485,60 @@ function init({
|
|
|
110485
110485
|
let filteredFolders = [];
|
|
110486
110486
|
if (!hasMetadataFilters && foldersResponse.status === "fulfilled" && foldersResponse.value) {
|
|
110487
110487
|
const foldersFromSearch = foldersResponse.value.results ?? [];
|
|
110488
|
+
const foldersToCache = foldersFromSearch.filter(
|
|
110489
|
+
(folder) => !state$2.folderCache[folder.id] && folder.parent_folder_id
|
|
110490
|
+
);
|
|
110491
|
+
if (foldersToCache.length > 0) {
|
|
110492
|
+
const parentIdsToFetch = Array.from(
|
|
110493
|
+
new Set(foldersToCache.map((f) => f.parent_folder_id).filter(Boolean))
|
|
110494
|
+
).filter((parentId) => {
|
|
110495
|
+
const hasUncachedChildren = foldersToCache.some(
|
|
110496
|
+
(f) => f.parent_folder_id === parentId && !state$2.folderCache[f.id]
|
|
110497
|
+
);
|
|
110498
|
+
return hasUncachedChildren;
|
|
110499
|
+
});
|
|
110500
|
+
await Promise.all(
|
|
110501
|
+
parentIdsToFetch.map(async (parentId) => {
|
|
110502
|
+
try {
|
|
110503
|
+
const parentFolder = await state$2.folderItemsFetcher?.(parentId, {
|
|
110504
|
+
justFetch: true,
|
|
110505
|
+
setSelectedFolder: false
|
|
110506
|
+
});
|
|
110507
|
+
if (parentFolder) {
|
|
110508
|
+
state$2.folderCache[parentId] = {
|
|
110509
|
+
files_count: parentFolder.files.length,
|
|
110510
|
+
folders_count: parentFolder.folders.length,
|
|
110511
|
+
available_files_count: parentFolder.files.filter((f) => {
|
|
110512
|
+
const isExpired = f.expires_at && new Date(f.expires_at) < /* @__PURE__ */ new Date();
|
|
110513
|
+
return !f.deleted_at && !isExpired;
|
|
110514
|
+
}).length,
|
|
110515
|
+
available_folders_count: parentFolder.folders.filter((sf) => {
|
|
110516
|
+
return (sf.files_count > 0 || sf.folders_count > 0) && (sf.available_files_count !== 0 || sf.available_folders_count !== 0);
|
|
110517
|
+
}).length,
|
|
110518
|
+
timestamp: Date.now()
|
|
110519
|
+
};
|
|
110520
|
+
parentFolder.folders.forEach((subfolder) => {
|
|
110521
|
+
state$2.folderCache[subfolder.id] = {
|
|
110522
|
+
files_count: subfolder.files_count,
|
|
110523
|
+
folders_count: subfolder.folders_count,
|
|
110524
|
+
available_files_count: subfolder.available_files_count,
|
|
110525
|
+
available_folders_count: subfolder.available_folders_count,
|
|
110526
|
+
timestamp: Date.now()
|
|
110527
|
+
};
|
|
110528
|
+
});
|
|
110529
|
+
}
|
|
110530
|
+
} catch (error) {
|
|
110531
|
+
console.error(`Failed to fetch parent folder ${parentId}:`, error);
|
|
110532
|
+
}
|
|
110533
|
+
})
|
|
110534
|
+
);
|
|
110535
|
+
}
|
|
110488
110536
|
filteredFolders = foldersFromSearch.map((folder) => {
|
|
110489
110537
|
const cached = state$2.folderCache[folder.id];
|
|
110490
110538
|
const parentCached = folder.parent_folder_id ? state$2.folderCache[folder.parent_folder_id] : null;
|
|
110539
|
+
if (cached && cached.available_files_count !== void 0 && cached.available_folders_count !== void 0 && cached.available_files_count === 0 && cached.available_folders_count === 0) {
|
|
110540
|
+
return null;
|
|
110541
|
+
}
|
|
110491
110542
|
if (parentCached && parentCached.available_folders_count !== void 0 && parentCached.available_folders_count === 0) {
|
|
110492
110543
|
return null;
|
|
110493
110544
|
}
|