Skip to content

Commit

Permalink
Merge pull request #9419 from owncloud/fix-use-window-open-composable
Browse files Browse the repository at this point in the history
fix: gettext and store usage in `useWindowOpen` composable
  • Loading branch information
JammingBen authored Jul 17, 2023
2 parents b05d9fe + 7e7f88d commit 3b73517
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ so that redirects and e.g. opening a resource in a new tab can work properly.

https://github.com/owncloud/web/issues/9377
https://github.com/owncloud/web/pull/9383
https://github.com/owncloud/web/pull/9419
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const useFileActions = ({ store }: { store?: Store<any> } = {}) => {
return !!unref(appProviders).find((appProvider) => appProvider.enabled)
})

const { openUrl } = useWindowOpen
const { openUrl } = useWindowOpen()

const { actions: acceptShareActions } = useFileActionsAcceptShare({ store })
const { actions: copyActions } = useFileActionsCopy({ store })
Expand Down
32 changes: 16 additions & 16 deletions packages/web-pkg/src/composables/actions/useWindowOpen.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { useGettext } from 'vue3-gettext'
import { useStore } from 'web-pkg/src/composables'

const openUrl = (url: string, target?: string, shouldFocus?: boolean) => {
export const useWindowOpen = () => {
const { $gettext } = useGettext()
const store = useStore()

const win = window.open(url, target)
const openUrl = (url: string, target?: string, shouldFocus?: boolean) => {
const win = window.open(url, target)

if (!win) {
store.dispatch('showMessage', {
title: $gettext('Pop-up and redirect block detected'),
timeout: 20,
status: 'warning',
desc: $gettext(
'Please turn on pop-ups and redirects in your browser settings to make sure everything works right.'
)
})
} else if (shouldFocus) {
win.focus()
if (!win) {
store.dispatch('showMessage', {
title: $gettext('Pop-up and redirect block detected'),
timeout: 20,
status: 'warning',
desc: $gettext(
'Please turn on pop-ups and redirects in your browser settings to make sure everything works right.'
)
})
} else if (shouldFocus) {
win.focus()
}
}
}

export const useWindowOpen = {
openUrl
return { openUrl }
}

0 comments on commit 3b73517

Please sign in to comment.