Cancel pending inpage request on overlay being dismissed

This commit is contained in:
Ivan Grachev 2022-08-28 22:16:28 +03:00
parent b5beb3e3db
commit 707a15de62
3 changed files with 9 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -110,6 +110,11 @@ function deliverResponseToSpecificProvider(id, response, provider) {
window.tokenary.overlayTapped = () => {
window.tokenary.hideOverlay();
const request = window.tokenary.overlayConfiguration.request;
deliverResponseToSpecificProvider(request.id, {id: request.id, error: "Canceled", name: request.name}, request.provider);
// TODO: cancel pending request in extension pipeline
// window.tokenary.postMessage(name, id, body, provider)
};
window.tokenary.hideOverlay = () => {
@ -144,7 +149,7 @@ window.tokenary.createOverlay = () => {
};
window.tokenary.overlayButtonTapped = () => {
const overlayConfiguration = window.tokenary.overlayConfiguration;
window.location.href = "https://tokenary.io/extension?query=" + encodeURIComponent(JSON.stringify(overlayConfiguration));
const request = window.tokenary.overlayConfiguration.request;
window.location.href = "https://tokenary.io/extension?query=" + encodeURIComponent(JSON.stringify(request));
window.tokenary.hideOverlay();
};

View File

@ -27,7 +27,7 @@ function platformSpecificProcessMessage(message) {
// + если он inpage будет отвечать на запрос ошибкой, то мне нужно будет как-то подчищать тот запрос, который ушел extension handler-у
// или на iOS сделать так, чтобы запрос extension handler-у не уходил до того момента, пока он не нажал на overlay кнопку
const response = {overlayConfiguration: message};
const response = {overlayConfiguration: {request: message}};
window.postMessage({direction: "from-content-script", response: response, id: message.id}, "*");
}