From 9c36194c2d4827dba0dc25159efdb7ab0884aef8 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Wed, 13 Nov 2024 08:47:27 +0100 Subject: [PATCH] fix: preview app image navigation on shared with me page --- .../bugfix-preview-app-shared-with-me-page | 6 +++++ .../appDefaults/useAppFolderHandling.ts | 27 +++++++++++++++---- .../resources/useCanListVersions.ts | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/bugfix-preview-app-shared-with-me-page diff --git a/changelog/unreleased/bugfix-preview-app-shared-with-me-page b/changelog/unreleased/bugfix-preview-app-shared-with-me-page new file mode 100644 index 00000000000..3416e4150b9 --- /dev/null +++ b/changelog/unreleased/bugfix-preview-app-shared-with-me-page @@ -0,0 +1,6 @@ +Bugfix: Preview app Shared with me page + +We fixed a navigation issue with the preview app on the Shared with me page. + +https://github.com/owncloud/web/issues/11883 +https://github.com/owncloud/web/pull/11893 diff --git a/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts b/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts index 5664c3fa035..b876ff42528 100644 --- a/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts +++ b/packages/web-pkg/src/composables/appDefaults/useAppFolderHandling.ts @@ -2,14 +2,14 @@ import { Ref, ref, unref, MaybeRef } from 'vue' import { dirname } from 'path' import { ClientService } from '../../services' import { useAppFileHandling } from './useAppFileHandling' -import { Resource } from '@ownclouders/web-client' +import { buildIncomingShareResource, 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, useSpacesStore } from '../piniaStores' +import { useResourcesStore, useSharesStore, useSpacesStore } from '../piniaStores' import { storeToRefs } from 'pinia' interface AppFolderHandlingOptions { @@ -29,22 +29,39 @@ export function useAppFolderHandling({ clientService }: AppFolderHandlingOptions): AppFolderHandlingResult { const isFolderLoading = ref(false) - const { webdav } = clientService + const { webdav, graphAuthenticated } = clientService const { replaceInvalidFileRoute } = useFileRouteReplace() const { getFileInfo } = useAppFileHandling({ clientService }) const authService = useAuthService() const spacesStore = useSpacesStore() + const sharesStore = useSharesStore() const resourcesStore = useResourcesStore() const { activeResources } = storeToRefs(resourcesStore) const loadFolderForFileContext = async (context: MaybeRef) => { isFolderLoading.value = true - resourcesStore.clearResourceList() + try { context = unref(context) - const space = unref(context.space) + 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 }) + isFolderLoading.value = false + return + } + + resourcesStore.clearResourceList() + const space = unref(context.space) const pathResource = await getFileInfo(context, { davProperties: [DavProperty.FileId] }) diff --git a/packages/web-pkg/src/composables/resources/useCanListVersions.ts b/packages/web-pkg/src/composables/resources/useCanListVersions.ts index d3f6aa97c03..5ad552cfc19 100644 --- a/packages/web-pkg/src/composables/resources/useCanListVersions.ts +++ b/packages/web-pkg/src/composables/resources/useCanListVersions.ts @@ -14,7 +14,7 @@ export const useCanListVersions = () => { if (isTrashResource(resource)) { return false } - return space.canListVersions({ user: userStore.user }) + return space?.canListVersions({ user: userStore.user }) } return {