diff --git a/scripts/pages/popup.js b/scripts/pages/popup.js index 3978dd0..906255c 100644 --- a/scripts/pages/popup.js +++ b/scripts/pages/popup.js @@ -3,7 +3,7 @@ */ // Import modules. -import {session, observe} from "/scripts/secretariat.js"; +import {session} from "/scripts/secretariat.js"; import Window from "/scripts/GUI/window.js"; import Page from "/scripts/pages/page.js"; import Loader from "/scripts/GUI/loader.js"; @@ -17,7 +17,8 @@ class Page_Popup extends Page { }; async background() { - observe(() => {this.content();}); + // Wait until a change in the session storage. + } async loading() { @@ -25,26 +26,24 @@ class Page_Popup extends Page { } async switch() { - // Get the last edited site. - let SITE = {}; - SITE.url = await session.read([`last`]); - SITE.details = await session.read([`sites`, SITE.url]); - let PAGES = { "results": "results.htm", "loading": "load.htm", "error": "error.htm" } - - console.log(PAGES); + + // Get the last edited site. + let SITE = {}; + SITE = await session.read([`last`], -1); + SITE.details = (SITE.url) ? await session.read([`sites`, SITE.url]) : null; + // Set the relative chrome URLs (Object.keys(PAGES)).forEach(PAGE => { PAGES[PAGE] = chrome.runtime.getURL(`pages/popup/${PAGES[PAGE]}`); }); - // Check if the site is available. - if (SITE.details == null) { + if (SITE.url ? (!SITE.done) : true) { this.elements[`frame`].src = PAGES[`loading`]; } else if (SITE.details.error) { // Set the iframe src to display the error. @@ -61,7 +60,8 @@ class Page_Popup extends Page { // Check if the frame is available. if (this.elements[`frame`].length) { - this.switch() + await this.switch(); + // observe((DATA) => {this.switch();}); } else { this.loading(); }