Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

Commit

Permalink
Adjust logic to close panes. Mostly implements #69.
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicMaas committed Sep 4, 2018
1 parent aacc953 commit bd697a3
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/scripts/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ document.addEventListener('DOMContentLoaded', () => {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
// Send the message and then close the popup
Message.sendMessage(new OpenOnRemoteDeviceMessage(device.id, tabs[0].url));
window.close();
closeMenu();
});
});
});
Expand Down Expand Up @@ -214,14 +214,14 @@ document.addEventListener('DOMContentLoaded', () => {
attachClickEvent('login', () => {
// Send the message and close
Message.sendMessage(new LoginMessage());
window.close();
closeMenu();
});

// log out flow
attachClickEvent('logout', () => {
// Send the message and close
Message.sendMessage(new LogoutMessage('User initiated logout'));
window.close();
closeMenu();
});

// When the user changes the timeout field
Expand All @@ -233,3 +233,26 @@ document.addEventListener('DOMContentLoaded', () => {
function attachClickEvent(elementName: string, callback: (ev: MouseEvent) => any) {
document.getElementById(elementName).addEventListener('click', callback);
}

function closeMenu() {
if (typeof browser === 'undefined' || !browser) {
chrome.runtime.getPlatformInfo((platInfo) => {
if (platInfo.os === 'android') {
chrome.tabs.update({active: true});
} else {
window.close();
}
});
} else {
browser.runtime.getPlatformInfo().then((platInfo) => {
if (platInfo.os === 'android') {

// TODO, USE BELOW
// browser.tabs.update({active: true});
chrome.tabs.update({active: true});
} else {
window.close();
}
});
}
}

0 comments on commit bd697a3

Please sign in to comment.