Skip to content

Commit

Permalink
refactor: replace document.hidden with document.visibilityState
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiofdsantos committed Jan 26, 2022
1 parent c16a183 commit 0d0508d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const preventMultitabsPlugin: Plugin = (): void => {
})

document.addEventListener('visibilitychange', () => {
if (!document.hidden && !localStorage.open) {
if (document.visibilityState === 'visible' && !localStorage.open) {
location.reload()
}
})
Expand All @@ -30,7 +30,7 @@ const preventMultitabsPlugin: Plugin = (): void => {
if (event.key === 'open' && event.newValue !== uuid) {
if (window.$nuxt && event.newValue) {
window.$nuxt.setLayout('<%= options.layout %>')
} else if (!document.hidden) {
} else if (document.visibilityState === 'visible') {
location.reload()
}
}
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-prevent-multitabs",
"version": "1.0.1",
"version": "1.0.2",
"description": "NuxtJS module to prevent opening the app in multiple tabs",
"repository": "dogchef-be/nuxt-prevent-multitabs",
"license": "MIT",
Expand All @@ -23,7 +23,7 @@
"@nuxt/types": "^2.15.8",
"@nuxt/typescript-build": "^2.1.0",
"nuxt": "^2.15.8",
"typescript": "^4.5.4"
"typescript": "^4.5.5"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 0d0508d

Please sign in to comment.