Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preview app image navigation on shared with me page #11893

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Comment on lines +49 to +51
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described, this is a bit of a hacky solution. My original idea was to check the presence of a current folder. If none is given, we can assume that the user is on some page where there is no actual space (Shared with me page, search results, etc). In that case we basically want the same logic as the respective folder loader for this page. However, the folder loader currently lives in the files app... Would it maybe make sense to register folder loaders via extension? @dschmidt What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of the folder loaders was definitely to make them reusable from app contexts, but I'm not sure they really fit our concept of extensions.

At least I currently don't see a use case for third party folder loaders...

Can't we just move the folder loaders to web-pkg and use them here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a quick chat: for the upcoming release we want this quick fix in, as it's easy to backport to the stable branch.
In the long run we think it's best to move the folder loaders to web-pkg.
Making them extensions would be nice for consistency reasons and we can come up with theoretic use cases for that (i.e. when apps register new routes/views which should be reloadable ... but it seems a bit artificial at this point and we suggest to avoid the effort until it's actually needed)

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