mirror of
https://github.com/lil-org/tokenary.git
synced 2024-11-30 13:02:49 +03:00
Deliver current latest configurations to app on iOS as well
This commit is contained in:
parent
f6ae749f73
commit
9281973d16
@ -2,14 +2,7 @@
|
||||
|
||||
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
if (request.subject === "message-to-wallet") {
|
||||
if ("name" in request.message, request.message.name == "switchAccount") {
|
||||
getLatestConfiguration(request.host, function(currentConfiguration) {
|
||||
request.message.body = currentConfiguration;
|
||||
sendNativeMessage(request, sender, sendResponse);
|
||||
});
|
||||
} else {
|
||||
sendNativeMessage(request, sender, sendResponse);
|
||||
}
|
||||
} else if (request.subject === "getResponse") {
|
||||
browser.runtime.sendNativeMessage("mac.tokenary.io", request, function(response) {
|
||||
sendResponse(response);
|
||||
@ -119,8 +112,13 @@ function justShowApp() {
|
||||
|
||||
browser.browserAction.onClicked.addListener(function(tab) {
|
||||
const message = {didTapExtensionButton: true};
|
||||
browser.tabs.sendMessage(tab.id, message, function(pong) {
|
||||
if (pong != true) {
|
||||
browser.tabs.sendMessage(tab.id, message, function(host) {
|
||||
if (typeof host !== "undefined") {
|
||||
getLatestConfiguration(host, function(currentConfiguration) {
|
||||
const switchAccountMessage = {name: "switchAccount", id: genId(), provider: "unknown", body: currentConfiguration};
|
||||
browser.tabs.sendMessage(tab.id, switchAccountMessage);
|
||||
});
|
||||
} else {
|
||||
justShowApp();
|
||||
}
|
||||
});
|
||||
|
@ -110,17 +110,12 @@ function sendMessageToNativeApp(message) {
|
||||
platformSpecificProcessMessage(message); // iOS opens app here
|
||||
}
|
||||
|
||||
function didTapExtensionButton() {
|
||||
const id = genId();
|
||||
const message = {name: "switchAccount", id: id, provider: "unknown", body: {}};
|
||||
sendMessageToNativeApp(message);
|
||||
}
|
||||
|
||||
// Receive from background
|
||||
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
if ("didTapExtensionButton" in request) {
|
||||
sendResponse(true);
|
||||
didTapExtensionButton();
|
||||
sendResponse(window.location.host);
|
||||
} else if ("name" in request && request.name == "switchAccount") {
|
||||
sendMessageToNativeApp(request);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user