Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring to front exist popup #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/js/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import storage from './util/storage.js';

let contentScriptPort = null;
let popupPort = null;
let popupId = null;
const queueToPopup = [];

const showExtensionPopup = () => {
if (popupId) {
chrome.windows.update(popupId, { focused: true });
return;
}
const cb = (currentPopup) => {
// this._popupId = currentPopup.id
popupId = currentPopup.id;
};
const creation = chrome.windows.create({
url: 'popup.html',
Expand Down Expand Up @@ -1001,9 +1006,7 @@ class Controller {

requestPublicKey(needQueue) {
return new Promise((resolve, reject) => {
if (!popupPort) {
showExtensionPopup();
}
showExtensionPopup();

this.afterEnterPassword = async words => {
const privateKey = await Controller.wordsToPrivateKey(words);
Expand Down Expand Up @@ -1042,9 +1045,7 @@ class Controller {
return (this.balance ? this.balance.toString() : '');
case 'ton_sendTransaction':
const param = params[0];
if (!popupPort) {
showExtensionPopup();
}
showExtensionPopup();
if (param.data) {
if (param.dataType === 'hex') {
param.data = TonWeb.utils.hexToBytes(param.data);
Expand All @@ -1061,9 +1062,7 @@ class Controller {
return true;
case 'ton_rawSign':
const signParam = params[0];
if (!popupPort) {
showExtensionPopup();
}
showExtensionPopup();
return this.showSignConfirm(signParam.data, needQueue);
case 'flushMemoryCache':
await chrome.webRequest.handlerBehaviorChanged();
Expand Down Expand Up @@ -1112,6 +1111,7 @@ if (IS_EXTENSION) {
});
popupPort.onDisconnect.addListener(() => {
popupPort = null;
popupId = null;
});

const runQueueToPopup = () => {
Expand Down