Skip to content

Commit

Permalink
feat: Added debug mode, to increase log verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimple committed May 24, 2022
1 parent 7a796f1 commit 75bd341
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 29 deletions.
14 changes: 7 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ gulp.task("default", function () {
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand All @@ -98,7 +98,7 @@ gulp.task("default", function () {
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand All @@ -112,7 +112,7 @@ gulp.task("default", function () {
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand All @@ -126,7 +126,7 @@ gulp.task("default", function () {
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand All @@ -142,7 +142,7 @@ gulp.task("default", function () {
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand All @@ -156,7 +156,7 @@ gulp.task("default", function () {
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand All @@ -171,7 +171,7 @@ gulp.task(
"purge-unused-css",
"fix-windows",
"build-ts",
"minify-scripts",
//"minify-scripts",
"fix-version",
"build-archive"
)
Expand Down
36 changes: 20 additions & 16 deletions src/scripts/destiny2/apiClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -904,24 +904,28 @@ export class DestinyApiClient {
savedAmount = 0;
log("CHARACTER-HISTORY", `Loading page ${page} (${historyActivityUrl})`);
var history = await pluginClient.GET(historyActivityUrl, await getUserToken());

let data = JSON.parse(history.Result.content);
if (data.Response.activities) {
log("CHARACTER-HISTORY", `Got ${data.Response.activities.length} activities`);
for (let activity of data.Response.activities) {
if ((await db.getStorageItem("playerActivity", activity.activityDetails.instanceId)) === null) {
await db.setStorageItem("playerActivity", activity.activityDetails.instanceId, {
characterId: characterId,
activity: activity,
});
try {
let data = JSON.parse(history.Result.content);
if (data.Response.activities) {
log("CHARACTER-HISTORY", `Got ${data.Response.activities.length} activities`);
for (let activity of data.Response.activities) {
if ((await db.getStorageItem("playerActivity", activity.activityDetails.instanceId)) === null) {
await db.setStorageItem("playerActivity", activity.activityDetails.instanceId, {
characterId: characterId,
activity: activity,
});
}
savedAmount++;
}
savedAmount++;
eventEmitter.emit("character-history-partial-loaded", {
membershipId,
characterId,
});
log("CHARACTER-HISTORY", `Saved ${savedAmount} activities`);
}
eventEmitter.emit("character-history-partial-loaded", {
membershipId,
characterId,
});
log("CHARACTER-HISTORY", `Saved ${savedAmount} activities`);
} catch (e) {
log("CHARACTER-HISTORY", "Failed to load character history", e, history);
reject(history.Result.content);
}

page++;
Expand Down
13 changes: 10 additions & 3 deletions src/scripts/destiny2/goalItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export class Destiny2Goals {

if (milestone.availableQuests && milestone.availableQuests.length > 0) {
for (let quest of milestone.availableQuests) {
if (quest.tracked) {
milestoneDataItem.tracked = true;
}
if (quest.status.started && !quest.status.completed) {
if (quest.status.stepObjectives && quest.status.stepObjectives.length > 0) {
for (let step of quest.status.stepObjectives) {
Expand Down Expand Up @@ -158,7 +161,8 @@ export class Destiny2Goals {
type: "bounty",
inProgressValueStyle: 0,
completedValueStyle: 0,
tracked: bounty.state == 2,
tracked: (bounty.state & 2) == 2,
state: bounty.state,
};

if (typeof bounty.expirationDate !== "undefined") {
Expand Down Expand Up @@ -229,7 +233,8 @@ export class Destiny2Goals {
type: "quest",
inProgressValueStyle: 0,
completedValueStyle: 0,
tracked: instanceQuest.state == 2,
tracked: (instanceQuest.state & 2) == 2,
state: instanceQuest.state,
};

if (typeof objective.completionValue !== "undefined") {
Expand Down Expand Up @@ -272,7 +277,8 @@ export class Destiny2Goals {
type: "quest",
inProgressValueStyle: 0,
completedValueStyle: 0,
tracked: uninstancedQuest.state == 2,
tracked: (uninstancedQuest.state & 2) == 2,
state: uninstancedQuest.state,
};

if (typeof objective.completionValue !== "undefined") {
Expand Down Expand Up @@ -328,6 +334,7 @@ export class Destiny2Goals {
nextLevelAt: objective.completionValue,
inProgressValueStyle: objective.objectiveInProgressValueStyle,
completedValueStyle: objective.objectiveCompletedValueStyle,
state: characterRecord.state,
};

characterRecords.push(characterRecordData);
Expand Down
5 changes: 2 additions & 3 deletions src/scripts/eventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export class EventEmitter {
constructor() {
this.eventListeners = [];

this.logArguments = false;

/**
* Listen to an event sent from this event emitter
* @param {String} eventName The event that you want to listen to
Expand All @@ -22,7 +20,8 @@ export class EventEmitter {
* @param {any} arguments
*/
this.emit = async function (eventName, ...params) {
if (this.logArguments) {
let logArguments = JSON.parse((await db.getItem("d2-debugmode")) ?? "false");
if (logArguments) {
log("EVENT:EMITTING", eventName, ...params);
} else {
log("EVENT:EMITTING", eventName);
Expand Down
18 changes: 18 additions & 0 deletions src/scripts/react/MainWindow/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export function Settings() {
await db.setItem("d2-track-records", checked);
eventEmitter.emit("tracked-items-changed");
});

document.getElementById("debugMode").addEventListener("change", async function (event) {
let checked = event.target.checked;
await db.setItem("d2-debugmode", checked);
eventEmitter.emit("debug-changed", checked);
});
});
});

Expand Down Expand Up @@ -75,6 +81,12 @@ export function Settings() {
)
? "checked"
: "";

document.getElementById("debugMode").checked = JSON.parse(
((await db.getItem("d2-debugmode")) ?? "false").toString()
)
? "checked"
: "";
}

return (
Expand Down Expand Up @@ -150,6 +162,12 @@ export function Settings() {
<code className="selectable-text">%localappdata%\Overwolf\Log</code> and zip up the folder so we can
get you back to achieving your goals.
</p>
<div className="form-check">
<input type="checkbox" className="form-check-input" id="debugMode" />
<label htmlFor="debugMode" className="form-check-label">
Enable debug mode
</label>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 75bd341

Please sign in to comment.