Skip to content

Commit

Permalink
fix: Can open shortcut even on preview page
Browse files Browse the repository at this point in the history
We had a bug that caused an issue where if we wanted
to open a shortcut from the preview page, it wouldn't
work.

Indeed, since we were only testing the public case
and forgetting the preview case, it couldn't work.

So now, we rely on the props to be able to know if we
are public or not instead of just checking the url.
  • Loading branch information
Crash-- committed Apr 5, 2024
1 parent 24a8ffa commit 8e8f4b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/modules/views/Folder/createFileOpeningHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const createFileOpeningHandler =
Alerter.error('alert.could_not_open_file')
}
} else {
const url = generateShortcutUrl({ file, client, isFlatDomain })
const url = generateShortcutUrl({
file,
client,
isFlatDomain,
fromPublicFolder
})
openInNewTab(url)
}
} else if (isNote) {
Expand Down
11 changes: 8 additions & 3 deletions src/modules/views/Folder/generateShortcutUrl.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { generateWebLink } from 'cozy-client'

const generateShortcutUrl = ({ file, client, isFlatDomain }) => {
const generateShortcutUrl = ({
file,
client,
isFlatDomain,
fromPublicFolder
}) => {
const currentURL = new URL(window.location)
let webLink = ''
if (currentURL.pathname === '/public') {
if (fromPublicFolder) {
webLink = generateWebLink({
cozyUrl: client.getStackClient().uri,
pathname: '/public',
pathname: currentURL.pathname,
slug: 'drive',
hash: `external/${file.id}`,
searchParams: currentURL.searchParams,
Expand Down

0 comments on commit 8e8f4b8

Please sign in to comment.