Skip to content

Commit

Permalink
use debug-info in infobar
Browse files Browse the repository at this point in the history
  • Loading branch information
FreekBes committed Nov 21, 2023
1 parent 120b127 commit 84acf54
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export class Authenticator {
}
catch (err) {
console.error(err);
if (this._authEvents) {
this._authEvents.errorMessage(String(err));
}
}
});

Expand All @@ -93,6 +96,9 @@ export class Authenticator {
}
catch (err) {
console.error(err);
if (this._authEvents) {
this._authEvents.errorMessage(String(err));
}
}
});

Expand Down Expand Up @@ -180,6 +186,9 @@ export class Authenticator {
}
catch (err) {
console.error(err);
if (this._authEvents) {
this._authEvents.errorMessage(String(err));
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions scripts/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class Wallpaper {
this._exists = (dirFiles !== undefined && dirFiles.includes(this._path));
if (!this._exists) {
console.warn('Wallpaper file does not exist: ' + this._path);
window.ui.setDebugInfo(`Wallpaper file does not exist: ${this._path}`);
}
}

Expand Down Expand Up @@ -159,6 +160,11 @@ export class Data {
.then(response => response.json())
.then(data => {
console.log("Fetched data.json", data);
if ("error" in data) {
console.warn("data.json response contains an error", data);
window.ui.setDebugInfo(`data.json response contains an error: ${data.error}`);
return;
}
this._dataJson = data;
// Emit data change event to all listeners
for (const listener of this._dataChangeListeners) {
Expand All @@ -167,6 +173,7 @@ export class Data {
})
.catch(error => {
console.error("Failed to fetch data.json", error);
window.ui.setDebugInfo(`Error fetching data.json: ${error}`);
});
}
}
5 changes: 5 additions & 0 deletions scripts/ui/infobars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class InfoBarsUI {
this._populateInfoElements();
}

public setDebugInfo(info: string): void {
this._infoElements.debug.innerText = info;
console.debug("Changed text in debug info: ", info);
}

private _populateInfoElements(): void {
// Populate debug info
this._infoElements.debug.innerText = '';
Expand Down
1 change: 1 addition & 0 deletions scripts/ui/lockscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class LockScreenUI extends UIScreen {
},
errorMessage: (message: string) => {
alert(message);
window.ui.setDebugInfo(message);
},
infoMessage: (message: string) => {
alert(message);
Expand Down
1 change: 1 addition & 0 deletions scripts/ui/loginscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class LoginScreenUI extends UIScreen {
},
errorMessage: (message: string) => {
alert(message);
window.ui.setDebugInfo(message);
},
infoMessage: (message: string) => {
alert(message);
Expand Down
4 changes: 4 additions & 0 deletions scripts/ui/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ export class UI {
public get isLockScreen(): boolean {
return this._isLockScreen;
}

public setDebugInfo(info: string): void {
this._infoBars.setDebugInfo(info);
}
}

0 comments on commit 84acf54

Please sign in to comment.