@ -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 ) = > {