aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/basecamp
diff options
context:
space:
mode:
authorLibravatar Prasanna <mail.prasanna.v@gmail.com>2021-07-07 10:54:04 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-07-07 11:36:50 +0530
commitfdb8f055927402195d27b08899b0e29305c29d27 (patch)
tree6ae39f67b02542b621df1593a9ce67b06f843b38 /recipes/basecamp
parentfix: Rocket.Chat tab doesn't display notifications (diff)
downloadferdium-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/basecamp')
-rw-r--r--recipes/basecamp/package.json2
-rw-r--r--recipes/basecamp/webview.js9
2 files changed, 9 insertions, 2 deletions
diff --git a/recipes/basecamp/package.json b/recipes/basecamp/package.json
index 7499ca6..c12a22b 100644
--- a/recipes/basecamp/package.json
+++ b/recipes/basecamp/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "basecamp", 2 "id": "basecamp",
3 "name": "basecamp", 3 "name": "basecamp",
4 "version": "1.0.1", 4 "version": "1.0.2",
5 "description": "Basecamp plugin for ferdi.", 5 "description": "Basecamp plugin for ferdi.",
6 "main": "index.js", 6 "main": "index.js",
7 "author": "", 7 "author": "",
diff --git a/recipes/basecamp/webview.js b/recipes/basecamp/webview.js
index 2158d0b..80cb8de 100644
--- a/recipes/basecamp/webview.js
+++ b/recipes/basecamp/webview.js
@@ -4,6 +4,13 @@ module.exports = (Franz, options) => {
4 let updates = 0; 4 let updates = 0;
5 const modal = document.createElement('div'); 5 const modal = document.createElement('div');
6 6
7 const waitFor = (condition, callback) => {
8 if (!condition()) {
9 window.setTimeout(waitFor.bind(null, condition, callback), 100);
10 } else {
11 callback();
12 }
13 };
7 function showModal (text) { 14 function showModal (text) {
8 show(modal); 15 show(modal);
9 modal.querySelector('p').innerHTML = text; 16 modal.querySelector('p').innerHTML = text;
@@ -47,7 +54,7 @@ module.exports = (Franz, options) => {
47 modal.id = 'franz-modal'; 54 modal.id = 'franz-modal';
48 modal.innerHTML = '<div class="modal-content"><span class="close">&times;</span><p></p></div>'; 55 modal.innerHTML = '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
49 modal.querySelector('.close').addEventListener('click', hideModal); 56 modal.querySelector('.close').addEventListener('click', hideModal);
50 document.body.appendChild(modal); 57 waitFor(() => document.body, () => document.body.appendChild(modal));
51 58
52 document.addEventListener('keydown', function(e) { if (e.keyCode === 27) { hideModal(); } }) 59 document.addEventListener('keydown', function(e) { if (e.keyCode === 27) { hideModal(); } })
53 60