diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-09-28 17:09:59 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-09-28 17:49:55 +0200 |
commit | 6dde0754257e58adb38b64e5cb5239ea63989b49 (patch) | |
tree | fda4589c8bfbab37898800f6fff63c62b8c8e5c6 /app/javascript/flavours/glitch/features | |
parent | f8205b7b4a6f9ec5a7ce0546b67aa0f6cbf54eef (diff) |
Fix actions being performed before the redux state is set up
Diffstat (limited to 'app/javascript/flavours/glitch/features')
-rw-r--r-- | app/javascript/flavours/glitch/features/ui/index.js | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/app/javascript/flavours/glitch/features/ui/index.js b/app/javascript/flavours/glitch/features/ui/index.js index a8fc1ad84..a399fc2b3 100644 --- a/app/javascript/flavours/glitch/features/ui/index.js +++ b/app/javascript/flavours/glitch/features/ui/index.js @@ -364,21 +364,6 @@ class UI extends React.Component { } componentWillMount () { - if (typeof document.hidden !== 'undefined') { // Opera 12.10 and Firefox 18 and later support - this.visibilityHiddenProp = 'hidden'; - this.visibilityChange = 'visibilitychange'; - } else if (typeof document.msHidden !== 'undefined') { - this.visibilityHiddenProp = 'msHidden'; - this.visibilityChange = 'msvisibilitychange'; - } else if (typeof document.webkitHidden !== 'undefined') { - this.visibilityHiddenProp = 'webkitHidden'; - this.visibilityChange = 'webkitvisibilitychange'; - } - if (this.visibilityChange !== undefined) { - document.addEventListener(this.visibilityChange, this.handleVisibilityChange, false); - this.handleVisibilityChange(); - } - window.addEventListener('beforeunload', this.handleBeforeUnload, false); document.addEventListener('dragenter', this.handleDragEnter, false); document.addEventListener('dragover', this.handleDragOver, false); @@ -402,6 +387,22 @@ class UI extends React.Component { this.hotkeys.__mousetrap__.stopCallback = (e, element) => { return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName) && !e.altKey; }; + + if (typeof document.hidden !== 'undefined') { // Opera 12.10 and Firefox 18 and later support + this.visibilityHiddenProp = 'hidden'; + this.visibilityChange = 'visibilitychange'; + } else if (typeof document.msHidden !== 'undefined') { + this.visibilityHiddenProp = 'msHidden'; + this.visibilityChange = 'msvisibilitychange'; + } else if (typeof document.webkitHidden !== 'undefined') { + this.visibilityHiddenProp = 'webkitHidden'; + this.visibilityChange = 'webkitvisibilitychange'; + } + + if (this.visibilityChange !== undefined) { + document.addEventListener(this.visibilityChange, this.handleVisibilityChange, false); + this.handleVisibilityChange(); + } } componentDidUpdate (prevProps) { |