mirror of
https://github.com/lil-org/wallet.git
synced 2025-01-01 08:54:06 +03:00
tune ios popup lifecycle
This commit is contained in:
parent
aca5a443ac
commit
901f9eb225
@ -1,7 +1,7 @@
|
||||
// Copyright © 2023 Tokenary. All rights reserved.
|
||||
|
||||
const button = document.getElementById('tokenary-button');
|
||||
const message = browser.extension.getBackgroundPage().pendingPopupRequest;
|
||||
var message = getPendingRequest();
|
||||
|
||||
if (message != null) {
|
||||
setupButton();
|
||||
@ -14,7 +14,11 @@ if (message != null) {
|
||||
}
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
const request = browser.extension.getBackgroundPage().pendingPopupRequest;
|
||||
var request = message;
|
||||
const fresh = getPendingRequest();
|
||||
if (fresh != null) {
|
||||
request = fresh;
|
||||
}
|
||||
const query = encodeURIComponent(JSON.stringify(request)) + '";';
|
||||
browser.tabs.executeScript({
|
||||
code: 'window.location.href = "https://tokenary.io/extension?query=' + query
|
||||
@ -58,3 +62,12 @@ function setupButton() {
|
||||
|
||||
button.innerText = title;
|
||||
}
|
||||
|
||||
function getPendingRequest() {
|
||||
const bg = browser.extension.getBackgroundPage();
|
||||
if (bg != null) {
|
||||
return bg.pendingPopupRequest;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user