-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9419 from owncloud/fix-use-window-open-composable
fix: gettext and store usage in `useWindowOpen` composable
- Loading branch information
Showing
3 changed files
with
18 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 16 additions & 16 deletions
32
packages/web-pkg/src/composables/actions/useWindowOpen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
} |