diff options
author | Vijay A <avijayr@protonmail.com> | 2021-08-13 09:07:33 +0530 |
---|---|---|
committer | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-08-13 07:32:56 +0000 |
commit | b2eef1daaa41313257e3f439d4d5604314c9ae2c (patch) | |
tree | 5fc0d7ff2d9c94d783ad166307f9e550a34086a2 /src/helpers | |
parent | chore: Replace old '@meetfranz/electron-notification-state' with 'macos-notif... (diff) | |
download | ferdium-app-b2eef1daaa41313257e3f439d4d5604314c9ae2c.tar.gz ferdium-app-b2eef1daaa41313257e3f439d4d5604314c9ae2c.tar.zst ferdium-app-b2eef1daaa41313257e3f439d4d5604314c9ae2c.zip |
fix(App): Fix app focus detection
Diffstat (limited to 'src/helpers')
-rw-r--r-- | src/helpers/visibility-helper.js | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/helpers/visibility-helper.js b/src/helpers/visibility-helper.js deleted file mode 100644 index 8456c4ecf..000000000 --- a/src/helpers/visibility-helper.js +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | export function onVisibilityChange(cb) { | ||
2 | let isVisible = true; | ||
3 | |||
4 | if (!cb) { | ||
5 | throw new Error('no callback given'); | ||
6 | } | ||
7 | |||
8 | function focused() { | ||
9 | if (!isVisible) { | ||
10 | cb(isVisible = true); | ||
11 | } | ||
12 | } | ||
13 | |||
14 | function unfocused() { | ||
15 | if (isVisible) { | ||
16 | cb(isVisible = false); | ||
17 | } | ||
18 | } | ||
19 | |||
20 | document.addEventListener('visibilitychange', () => { (document.hidden ? unfocused : focused)(); }); | ||
21 | |||
22 | window.onpageshow = focused; | ||
23 | window.onfocus = focused; | ||
24 | |||
25 | window.onpagehid = unfocused; | ||
26 | window.onblur = unfocused; | ||
27 | } | ||