diff --git a/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts b/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts index b876ff42528..a5413823e55 100644 --- a/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts +++ b/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts @@ -1,16 +1,17 @@ import { Ref, ref, unref, MaybeRef } from 'vue' import { dirname } from 'path' -import { ClientService } from '../../services' +import { ClientService, folderService } from '../../services' import { useAppFileHandling } from './useAppFileHandling' -import { buildIncomingShareResource, Resource } from '@ownclouders/web-client' +import { Resource } from '@ownclouders/web-client' import { FileContext } from './types' import { RouteLocationNormalizedLoaded } from 'vue-router' import { useFileRouteReplace } from '../router/useFileRouteReplace' import { DavProperty } from '@ownclouders/web-client/webdav' import { useAuthService } from '../authContext/useAuthService' import { isMountPointSpaceResource } from '@ownclouders/web-client' -import { useResourcesStore, useSharesStore, useSpacesStore } from '../piniaStores' +import { useResourcesStore, useSpacesStore } from '../piniaStores' import { storeToRefs } from 'pinia' +import { useRouteQuery } from '../router' interface AppFolderHandlingOptions { currentRoute: Ref @@ -29,12 +30,12 @@ export function useAppFolderHandling({ clientService }: AppFolderHandlingOptions): AppFolderHandlingResult { const isFolderLoading = ref(false) - const { webdav, graphAuthenticated } = clientService + const { webdav } = clientService const { replaceInvalidFileRoute } = useFileRouteReplace() const { getFileInfo } = useAppFileHandling({ clientService }) const authService = useAuthService() const spacesStore = useSpacesStore() - const sharesStore = useSharesStore() + const currentRouteQuery = useRouteQuery('contextRouteParams') const resourcesStore = useResourcesStore() const { activeResources } = storeToRefs(resourcesStore) @@ -45,17 +46,11 @@ export function useAppFolderHandling({ try { context = unref(context) - if (context.routeName === 'files-shares-with-me') { - // FIXME: this is a somewhat hacky solution to load the shared with me files. - // ideally we should check if there is a current folder and if not, use the - // folder loader to load files. unfortunately, it currently lives in the files app. - const driveItems = await graphAuthenticated.driveItems.listSharedWithMe() - - const resources = driveItems.map((driveItem) => - buildIncomingShareResource({ driveItem, graphRoles: sharesStore.graphRoles }) - ) - - resourcesStore.initResourceList({ currentFolder: null, resources }) + if (!(unref(currentRouteQuery) as any).driveAliasAndItem) { + // when there is no driveAliasAndItem, we are in a file list without space. + // use the folder loader in this case to load the resources. + const loaderTask = folderService.getTask() + await loaderTask.perform() isFolderLoading.value = false return } diff --git a/packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts b/packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts index 396c6b98928..8ee3f6dc715 100644 --- a/packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts +++ b/packages/web-pkg/src/services/folder/loaders/loaderSharedWithOthers.ts @@ -1,4 +1,5 @@ import { FolderLoader, FolderLoaderTask, TaskContext } from '../folderService' +import { unref } from 'vue' import { Router } from 'vue-router' import { useTask } from 'vue-concurrency' import { isLocationSharesActive } from '../../../router' @@ -10,7 +11,11 @@ export class FolderLoaderSharedWithOthers implements FolderLoader { } public isActive(router: Router): boolean { - return isLocationSharesActive(router, 'files-shares-with-others') + const currentRoute = unref(router.currentRoute) + return ( + isLocationSharesActive(router, 'files-shares-with-others') || + currentRoute?.query?.contextRouteName === 'files-shares-with-others' + ) } public getTask(context: TaskContext): FolderLoaderTask {