From 07c3aa4822aaf4c41a23e79cdd3a92b6c7faf517 Mon Sep 17 00:00:00 2001 From: NoLifeKing Date: Sat, 2 Oct 2021 08:11:05 +0200 Subject: [PATCH] feat: Made some loading asynchronous to speed up the time it took for the UI to get responsive --- src/scripts/destiny2/apiClient.js | 12 +++++++ src/scripts/eventEmitter.js | 10 ++++-- src/scripts/mainWindow.js | 54 ++++++++++++++++--------------- src/scss/overlay-styles.scss | 18 +++++++---- src/scss/window-styles.scss | 7 +++- src/windows/main-window.html | 8 +++-- 6 files changed, 69 insertions(+), 40 deletions(-) diff --git a/src/scripts/destiny2/apiClient.js b/src/scripts/destiny2/apiClient.js index 3c7c653..9e58bfe 100644 --- a/src/scripts/destiny2/apiClient.js +++ b/src/scripts/destiny2/apiClient.js @@ -195,6 +195,18 @@ function DestinyApiClient(d2ApiClient) { } }; + this.loadCommonSettings = async function () { + return new Promise(async (resolve, reject) => { + await pluginClient.GET( + `${destinyApiUrl}/Settings`, + await getUserToken(), + (response) => { + resolve(JSON.parse(response.content)); + } + ); + }); + }; + /** * @description Loads the manifest and then loads the content data. */ diff --git a/src/scripts/eventEmitter.js b/src/scripts/eventEmitter.js index ab7f13a..6a8ecee 100644 --- a/src/scripts/eventEmitter.js +++ b/src/scripts/eventEmitter.js @@ -16,13 +16,17 @@ function EventEmitter() { * @param {String} eventName * @param {any} arguments */ - this.emit = function (eventName, arguments) { + this.emit = async function (eventName, arguments) { log('EVENT:EMITTING', eventName); + return new Promise((resolve, reject) => { this.eventListeners .filter((ev) => ev.eventName == eventName) - .forEach((l) => { - l.handler(arguments); + .forEach(async (l) => { + await l.handler(arguments); }); + + resolve(true); + }); }; return this; diff --git a/src/scripts/mainWindow.js b/src/scripts/mainWindow.js index 5841c13..63f1b30 100644 --- a/src/scripts/mainWindow.js +++ b/src/scripts/mainWindow.js @@ -75,7 +75,32 @@ function onOwAdReady() { }); } -function loadSettings() {} +async function loadSettings() { + document.getElementById("visibleItems").value = await db.getItem( + "d2-visible-items" + ); + + document.getElementById("trackMilestones").checked = JSON.parse( + ((await db.getItem("d2-track-milestones")) ?? "true").toString() + ) + ? "checked" + : ""; + document.getElementById("trackBounties").checked = JSON.parse( + ((await db.getItem("d2-track-bounties")) ?? "true").toString() + ) + ? "checked" + : ""; + document.getElementById("trackQuests").checked = JSON.parse( + ((await db.getItem("d2-track-quests")) ?? "true").toString() + ) + ? "checked" + : ""; + document.getElementById("trackRecords").checked = JSON.parse( + ((await db.getItem("d2-track-records")) ?? "true").toString() + ) + ? "checked" + : ""; +} function downloadUpdate() { log("UPDATE", "User clicked the 'Update available!' text"); @@ -135,7 +160,7 @@ function bindExitButtonEvent(window) { }); } -(function () { +(async function () { overwolf.windows.getCurrentWindow(async function (window) { new DraggableWindow(window.window, document.getElementById("titleBar")); bindExitButtonEvent(window); @@ -145,30 +170,7 @@ function bindExitButtonEvent(window) { document.getElementById("titleBarName").innerHTML = windowTitle; }); - document.getElementById("visibleItems").value = await db.getItem( - "d2-visible-items" - ); - - document.getElementById("trackMilestones").checked = JSON.parse( - ((await db.getItem("d2-track-milestones")) ?? "true").toString() - ) - ? "checked" - : ""; - document.getElementById("trackBounties").checked = JSON.parse( - ((await db.getItem("d2-track-bounties")) ?? "true").toString() - ) - ? "checked" - : ""; - document.getElementById("trackQuests").checked = JSON.parse( - ((await db.getItem("d2-track-quests")) ?? "true").toString() - ) - ? "checked" - : ""; - document.getElementById("trackRecords").checked = JSON.parse( - ((await db.getItem("d2-track-records")) ?? "true").toString() - ) - ? "checked" - : ""; + await loadSettings(); document .getElementById("authenticateWithBungie") diff --git a/src/scss/overlay-styles.scss b/src/scss/overlay-styles.scss index bcf936a..3ce147f 100644 --- a/src/scss/overlay-styles.scss +++ b/src/scss/overlay-styles.scss @@ -57,6 +57,10 @@ background-color: #000; } +.badge { + letter-spacing: 1px; +} + body { height: 100vh; overflow: hidden; @@ -115,30 +119,30 @@ body { @media (max-width: 200px) { body { - font-size: 0.5rem; + font-size: 0.7rem; } .navbar-brand { - font-size: 0.9rem; + font-size: 0.8rem; } .media-body h5 { - font-size: 0.6rem; + font-size: 0.8rem; } h1 { - font-size: 1.7rem; + font-size: 1.9rem; } h2 { - font-size: 1.5rem; + font-size: 1.7rem; } h3 { - font-size: 1.1rem; + font-size: 1.3rem; } h4 { - font-size: 0.9rem; + font-size: 1.1rem; } } diff --git a/src/scss/window-styles.scss b/src/scss/window-styles.scss index 1e99e33..f17e0af 100644 --- a/src/scss/window-styles.scss +++ b/src/scss/window-styles.scss @@ -120,7 +120,7 @@ user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */ font-family: "Neue Haas Grotesk Display Pro 55 Roman"; - font-size: 18pt; + letter-spacing: 0.01rem; } @@ -155,4 +155,9 @@ body { overflow: hidden; background-image: url(../../images/vincenzo-malagoli-flfhAlEwDq4-unsplash.jpg); background-size: cover; + font-size: 18pt; +} + +.selectable-text { + user-select: text; } diff --git a/src/windows/main-window.html b/src/windows/main-window.html index 7802a20..ff9159d 100644 --- a/src/windows/main-window.html +++ b/src/windows/main-window.html @@ -66,8 +66,7 @@ GOALS AVAILABLE FOR TRACKING
- - +
@@ -100,7 +99,10 @@

Loading data

+ + +
@@ -153,7 +155,7 @@

What do you want the overlay to track?

SUPPORT

To help us help you out with potential issues and other things, we need you to send us your logs, which can be done by sending them to NoLifeKing on Discord! After you sent the logs, be sure to tell NoLifeKing that you've done so

-

You can find the logs located at %localappdata%\Overwolf\Log. Just zip the entire folder and send it to me.

+

You can find the logs located at %localappdata%\Overwolf\Log. Just zip the entire folder and send it to me.