Skip to content

Commit

Permalink
feat: Made some loading asynchronous to speed up the time it took for…
Browse files Browse the repository at this point in the history
… the UI to get responsive
  • Loading branch information
itssimple committed Oct 2, 2021
1 parent 5c374fc commit 07c3aa4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 40 deletions.
12 changes: 12 additions & 0 deletions src/scripts/destiny2/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
10 changes: 7 additions & 3 deletions src/scripts/eventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
54 changes: 28 additions & 26 deletions src/scripts/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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")
Expand Down
18 changes: 11 additions & 7 deletions src/scss/overlay-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
background-color: #000;
}

.badge {
letter-spacing: 1px;
}

body {
height: 100vh;
overflow: hidden;
Expand Down Expand Up @@ -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;
}
}
7 changes: 6 additions & 1 deletion src/scss/window-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
8 changes: 5 additions & 3 deletions src/windows/main-window.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
GOALS AVAILABLE FOR TRACKING
</div>
<div class="card-body">
<button class="btn btn-primary" id="authenticateWithBungie">Authenticate with Bungie.net</button>
<button class="btn btn-primary" id="logoutFromBungie">Log out from Bungie.net</button>

</div>
</div>
</div>
Expand Down Expand Up @@ -100,7 +99,10 @@ <h4 class="card-title" id="lastPlayedClass"><i>Loading data</i></h4>
</p>
</div>
</div>
<button class="btn btn-primary" style="width: 100%;" id="authenticateWithBungie">Authenticate with Bungie.net</button>
<button class="btn btn-primary" style="width: 100%;" id="logoutFromBungie">Log out from Bungie.net</button>
</div>

</div>
</div>
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab">
Expand Down Expand Up @@ -153,7 +155,7 @@ <h4>What do you want the overlay to track?</h4>
<h3>SUPPORT</h3>
<p class="form-text">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</p>
<p class="form-text">You can find the logs located at <code>%localappdata%\Overwolf\Log</code>. Just zip the entire folder and send it to me.</p>
<p class="form-text">You can find the logs located at <code class="selectable-text">%localappdata%\Overwolf\Log</code>. Just zip the entire folder and send it to me.</p>
</div>
</div>
</div>
Expand Down

0 comments on commit 07c3aa4

Please sign in to comment.