aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/store/files.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/store/files.ts')
-rw-r--r--apps/files/src/store/files.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/files/src/store/files.ts b/apps/files/src/store/files.ts
index f9024b0a6bd..1af675e67ce 100644
--- a/apps/files/src/store/files.ts
+++ b/apps/files/src/store/files.ts
@@ -14,6 +14,7 @@ import logger from '../logger'
import Vue from 'vue'
import { client } from '../services/WebdavClient.ts'
+import { usePathsStore } from './paths.ts'
const fetchNode = async (node: Node): Promise<Node> => {
const propfindPayload = davGetDefaultPropfind()
@@ -63,6 +64,33 @@ export const useFilesStore = function(...args) {
},
actions: {
+ /**
+ * Get cached nodes within a given path
+ *
+ * @param service The service (files view)
+ * @param path The path relative within the service
+ * @returns Array of cached nodes within the path
+ */
+ getNodesByPath(service: string, path?: string): Node[] {
+ const pathsStore = usePathsStore()
+ let folder: Folder | undefined
+
+ // Get the containing folder from path store
+ if (!path || path === '/') {
+ folder = this.getRoot(service)
+ } else {
+ const source = pathsStore.getPath(service, path)
+ if (source) {
+ folder = this.getNode(source) as Folder | undefined
+ }
+ }
+
+ // If we found a cache entry and the cache entry was already loaded (has children) then use it
+ return (folder?._children ?? [])
+ .map((source: string) => this.getNode(source))
+ .filter(Boolean)
+ },
+
updateNodes(nodes: Node[]) {
// Update the store all at once
const files = nodes.reduce((acc, node) => {