do presence announcement only after complete page load
This commit is contained in:
parent
29b107f937
commit
a6035dd4c7
@ -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() {
|
function init() {
|
||||||
// Only place where we don't use the nicer RPC wrapper, since the wallet
|
// Only place where we don't use the nicer RPC wrapper, since the wallet
|
||||||
// backend might not be ready (during install, upgrade, etc.)
|
// backend might not be ready (during install, upgrade, etc.)
|
||||||
chrome.runtime.sendMessage({type: "get-tab-cookie"}, (resp) => {
|
chrome.runtime.sendMessage({type: "get-tab-cookie"}, (resp) => {
|
||||||
|
logVerbose && console.log("got response for get-tab-cookie");
|
||||||
if (chrome.runtime.lastError) {
|
if (chrome.runtime.lastError) {
|
||||||
logVerbose && console.log("extension not yet ready");
|
logVerbose && console.log("extension not yet ready");
|
||||||
window.setTimeout(init, 200);
|
window.setTimeout(init, 200);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (document.documentElement.getAttribute("data-taler-nojs")) {
|
onceOnComplete(() => {
|
||||||
const onload = () => {
|
if (document.documentElement.getAttribute("data-taler-nojs")) {
|
||||||
initStyle();
|
initStyle();
|
||||||
setStyles(true);
|
setStyles(true);
|
||||||
};
|
|
||||||
if (document.readyState === "complete") {
|
|
||||||
onload();
|
|
||||||
} else {
|
|
||||||
document.addEventListener("DOMContentLoaded", onload);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
registerHandlers();
|
registerHandlers();
|
||||||
// Hack to know when the extension is unloaded
|
// Hack to know when the extension is unloaded
|
||||||
const port = chrome.runtime.connect();
|
const port = chrome.runtime.connect();
|
||||||
|
Loading…
Reference in New Issue
Block a user