Skip to content

Commit

Permalink
reload logic fixed. fixes mozilla#202
Browse files Browse the repository at this point in the history
  • Loading branch information
princiya committed Oct 14, 2017
1 parent 0d20cb3 commit ffd2295
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/js/lightbeamVR.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ const lightbeamVR = {
},

async runLightbeam() {
// Checks to see if Lightbeam is already open.
// Checks to see if LightbeamVR is already open.
// Returns true if it is, false if not.
let fullUrl = null;
const fullUrl = 'http://localhost:3000/';
async function isOpen() {
const tabs = await browser.tabs.query({});
fullUrl = browser.extension.getURL('http://localhost:3000');
const lightbeamTabs = tabs.filter((tab) => {
return (tab.url === fullUrl);
});
return lightbeamTabs[0] || false;
}

const lightbeamTab = await isOpen();
if (!lightbeamTab && fullUrl) {
if (!lightbeamTab) {
// only open a new LightbeamVR instance if one isn't already open.
browser.tabs.create({ url: fullUrl });
browser.tabs.create({ url: fullUrl});
} else if (!lightbeamTab.active) {
// re-focus LightbeamVR if it is already open but lost focus
browser.tabs.reload(lightbeamTab.id);
browser.tabs.update(lightbeamTab.id, {active: true});
}
}
Expand Down

0 comments on commit ffd2295

Please sign in to comment.