diff --git a/src/pat/contentbrowser/src/ContentBrowser.svelte b/src/pat/contentbrowser/src/ContentBrowser.svelte
index e44a3c9d7..79d6d531f 100644
--- a/src/pat/contentbrowser/src/ContentBrowser.svelte
+++ b/src/pat/contentbrowser/src/ContentBrowser.svelte
@@ -8,9 +8,7 @@
import { resolveIcon } from "./resolveIcon.js";
import Upload from "../../upload/upload";
- import {
- currentPath,
- } from "./stores.js";
+ import { currentPath } from "./stores.js";
// import Keydown from "svelte-keydown";
animateScroll.setGlobalOptions({
@@ -21,7 +19,7 @@
// get context stores
const config = getContext("config");
- const pathCache = getContext('pathCache');
+ const pathCache = getContext("pathCache");
const showContentBrowser = getContext("showContentBrowser");
const selectedItems = getContext("selectedItems");
const selectedUids = getContext("selectedUids");
@@ -54,7 +52,7 @@
allowPathSelection: false,
hiddenInputContainer: ".upload-wrapper",
success: (fileUpload, obj) => {
- contentItems.get($currentPath, null, true);
+ contentItems.get({ path: $currentPath, updateCache: true });
},
});
}
@@ -110,9 +108,15 @@
}
}
+ function loadMore(entries, observer) {
+ entries.forEach(async (entry) => {
+ if (entry.intersectionRatio === 0 || contentItems.loading) return;
+ await contentItems.loadMore(entry.target.dataset.path, $currentPath);
+ });
+ }
+
function itemInPath(item) {
- const inPath = $currentPath.indexOf(item.getPath) != -1;
- return inPath;
+ return $currentPath.indexOf(item.getPath) != -1;
}
function filterItems() {
@@ -121,19 +125,26 @@
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
- contentItems.get($currentPath, this.value);
+ contentItems.get({ path: $currentPath, searchTerm: this.value });
}, 300);
}
+ function initIntersectionObserver() {
+ for (const el of document.querySelectorAll(".load-more")) {
+ const observer = new IntersectionObserver(loadMore);
+ observer.observe(el);
+ }
+ }
+
$: {
- contentItems.get($currentPath, null, true);
+ contentItems.get({ path: $currentPath });
}
$: {
$contentItems;
scrollToRight();
+ initIntersectionObserver();
}
-
@@ -155,14 +166,14 @@
>
{#if $config.uploadEnabled}
-
+
{/if}
{/if}
{#if i > 0 && level.selectable}
@@ -202,21 +215,27 @@
{/if}
{#if !level.gridView}
-
+
{:else}
-
+
{/if}
- {#each (level.items || []) as item, n}
+ {#each level.items || [] as item, n}