summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-06-02 02:14:40 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-06-02 02:14:40 +0200
commita6035dd4c74bd83a1eb0deb37fb7b22a2e97fd39 (patch)
tree3ef5b90bf5deca2f346d0244492f09ca0e2b2aae
parent29b107f93763420c5bc0cbde38c68e40e705ff38 (diff)
downloadwallet-core-a6035dd4c74bd83a1eb0deb37fb7b22a2e97fd39.tar.gz
wallet-core-a6035dd4c74bd83a1eb0deb37fb7b22a2e97fd39.tar.bz2
wallet-core-a6035dd4c74bd83a1eb0deb37fb7b22a2e97fd39.zip
do presence announcement only after complete page load
-rw-r--r--src/webex/notify.ts25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/webex/notify.ts b/src/webex/notify.ts
index 09c5ae002..51abdb0e0 100644
--- a/src/webex/notify.ts
+++ b/src/webex/notify.ts
@@ -180,26 +180,35 @@ function handlePaymentResponse(maybeFoundResponse: QueryPaymentResult) {
}
+function onceOnComplete(cb: () => void) {
+ if (document.readyState === "complete") {
+ cb();
+ } else {
+ document.addEventListener("readystatechange", () => {
+ if (document.readyState === "complete") {
+ cb();
+ }
+ });
+ }
+}
+
+
function init() {
// Only place where we don't use the nicer RPC wrapper, since the wallet
// backend might not be ready (during install, upgrade, etc.)
chrome.runtime.sendMessage({type: "get-tab-cookie"}, (resp) => {
+ logVerbose && console.log("got response for get-tab-cookie");
if (chrome.runtime.lastError) {
logVerbose && console.log("extension not yet ready");
window.setTimeout(init, 200);
return;
}
- if (document.documentElement.getAttribute("data-taler-nojs")) {
- const onload = () => {
+ onceOnComplete(() => {
+ if (document.documentElement.getAttribute("data-taler-nojs")) {
initStyle();
setStyles(true);
- };
- if (document.readyState === "complete") {
- onload();
- } else {
- document.addEventListener("DOMContentLoaded", onload);
}
- }
+ });
registerHandlers();
// Hack to know when the extension is unloaded
const port = chrome.runtime.connect();