Skip to content

Commit

Permalink
fix: preview app image navigation on shared with me page
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Nov 13, 2024
1 parent b12a9a0 commit 9c36194
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-preview-app-shared-with-me-page
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<FileContext>) => {
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]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9c36194

Please sign in to comment.