diff options
author | 2021-07-07 10:54:04 +0530 | |
---|---|---|
committer | 2021-07-07 11:36:50 +0530 | |
commit | fdb8f055927402195d27b08899b0e29305c29d27 (patch) | |
tree | 6ae39f67b02542b621df1593a9ce67b06f843b38 /recipes/googlecalendar/webview.js | |
parent | fix: Rocket.Chat tab doesn't display notifications (diff) | |
download | ferdium-recipes-fdb8f055927402195d27b08899b0e29305c29d27.tar.gz ferdium-recipes-fdb8f055927402195d27b08899b0e29305c29d27.tar.zst ferdium-recipes-fdb8f055927402195d27b08899b0e29305c29d27.zip |
fixing a race condition where document body is null
Diffstat (limited to 'recipes/googlecalendar/webview.js')
-rw-r--r-- | recipes/googlecalendar/webview.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/recipes/googlecalendar/webview.js b/recipes/googlecalendar/webview.js index 3d2b6f6..469ff0c 100644 --- a/recipes/googlecalendar/webview.js +++ b/recipes/googlecalendar/webview.js | |||
@@ -6,6 +6,14 @@ module.exports = Franz => { | |||
6 | let modal; | 6 | let modal; |
7 | let updates = 0; | 7 | let updates = 0; |
8 | 8 | ||
9 | const waitFor = (condition, callback) => { | ||
10 | if (!condition()) { | ||
11 | window.setTimeout(waitFor.bind(null, condition, callback), 100); | ||
12 | } else { | ||
13 | callback(); | ||
14 | } | ||
15 | }; | ||
16 | |||
9 | const createModal = () => { | 17 | const createModal = () => { |
10 | const franzModal = document.createElement('div'); | 18 | const franzModal = document.createElement('div'); |
11 | franzModal.setAttribute('id', 'franz-modal'); | 19 | franzModal.setAttribute('id', 'franz-modal'); |
@@ -32,10 +40,10 @@ module.exports = Franz => { | |||
32 | const getMessages = () => Franz.setBadge(updates); | 40 | const getMessages = () => Franz.setBadge(updates); |
33 | 41 | ||
34 | modal = createModal(); | 42 | modal = createModal(); |
35 | document.body.appendChild(modal); | 43 | waitFor(() => document.body, () => document.body.appendChild(modal)); |
36 | document.addEventListener('keydown', event => event.keyCode === 27 && hideModal()); | 44 | document.addEventListener('keydown', event => event.keyCode === 27 && hideModal()); |
37 | 45 | ||
38 | Franz.injectCSS(path.join(__dirname, 'calendar.css')); | 46 | Franz.injectCSS(path.join(__dirname, 'calendar.css')); |
39 | Franz.loop(getMessages); | 47 | Franz.loop(getMessages); |
40 | }; | 48 | }; |
41 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdvb2dsZWNhbGVuZGFyL3dlYnZpZXcuanMiXSwibmFtZXMiOlsicGF0aCIsInJlcXVpcmUiLCJtb2R1bGUiLCJleHBvcnRzIiwiRnJhbnoiLCJtb2RhbCIsInVwZGF0ZXMiLCJjcmVhdGVNb2RhbCIsImZyYW56TW9kYWwiLCJkb2N1bWVudCIsImNyZWF0ZUVsZW1lbnQiLCJzZXRBdHRyaWJ1dGUiLCJpbm5lckhUTUwiLCJxdWVyeVNlbGVjdG9yIiwiYWRkRXZlbnRMaXN0ZW5lciIsImhpZGVNb2RhbCIsInNob3dNb2RhbCIsInRleHQiLCJjbGFzc0xpc3QiLCJhZGQiLCJyZW1vdmUiLCJ3aW5kb3ciLCJhbGVydCIsImdldE1lc3NhZ2VzIiwic2V0QmFkZ2UiLCJib2R5IiwiYXBwZW5kQ2hpbGQiLCJldmVudCIsImtleUNvZGUiLCJpbmplY3RDU1MiLCJqb2luIiwiX19kaXJuYW1lIiwibG9vcCJdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFNQSxPQUFPQyxRQUFRLE1BQVIsQ0FBYjs7QUFFQUMsT0FBT0MsT0FBUCxHQUFpQkMsU0FBUztBQUN4QixNQUFJQyxLQUFKO0FBQ0EsTUFBSUMsVUFBVSxDQUFkOztBQUVBLFFBQU1DLGNBQWMsTUFBTTtBQUN4QixVQUFNQyxhQUFhQyxTQUFTQyxhQUFULENBQXVCLEtBQXZCLENBQW5CO0FBQ0FGLGVBQVdHLFlBQVgsQ0FBd0IsSUFBeEIsRUFBOEIsYUFBOUI7QUFDQUgsZUFBV0ksU0FBWCxHQUF1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