Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 7820a3f

Browse files
committed
dev: debugging improvements
1 parent 6f27264 commit 7820a3f

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "msedge",
9+
"request": "launch",
10+
"name": "Launch Edge against localhost",
11+
"url": "http://localhost:3000",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
33
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
4-
"indentRainbow.indicatorStyle": "classic"
4+
"indentRainbow.indicatorStyle": "classic",
5+
"debug.javascript.unmapMissingSources": true
56
}

apps/client/src/consumers/sbhsApi/useDtt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import OAuth2Actions from "../../services/OAuth2Actions";
22
import { useAuthActions } from "../../services/UserInterface";
3+
import { log } from "../../utils/log";
34
import { dttSchema, sbhsKey } from "./schemas";
45
import { useQuery } from "@tanstack/react-query";
56

@@ -17,6 +18,7 @@ const queryFn = async (authActions: OAuth2Actions, date?: string) => {
1718
const getQueryKey = sbhsKey("timetable/daytimetable.json");
1819

1920
export const useDtt = (date?: string) => {
21+
log("useDtt hook mounted");
2022
const authActions = useAuthActions();
2123

2224
return useQuery({

apps/client/src/main.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ const fetchWrapper = new OAuth2Fetch({
8888
client: oauthClient,
8989

9090
getNewToken: () => {
91+
log("getNewToken invoked");
92+
9193
// Set the status to expired
9294
useAuthStore.setState({ status: AuthStatus.EXPIRED });
9395

@@ -133,6 +135,8 @@ const userInterface = new UserInterface(
133135
// Initialise analytics
134136
inject();
135137

138+
authActions.resolve();
139+
136140
// Render root
137141
userInterface.render();
138142

@@ -158,7 +162,3 @@ log(
158162
console.log(
159163
"SELF-XSS WARNING - PLEASE DON'T DO PASTE ANYTHING INTO HERE FROM PLACES YOU DON'T TRUST!!!"
160164
);
161-
// Initialise authentication
162-
addEventListener("load", () => {
163-
authActions.resolve();
164-
});

apps/client/src/services/OAuth2Actions/OAuth2Actions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,16 @@ class OAuth2Actions implements AuthActions {
139139
};
140140

141141
public logout = async () => {
142+
const debugMode = localStorage.getItem("debug") === "true";
143+
142144
// Clear localstorage
143145
localStorage.clear();
144146

147+
// Persist debug mode
148+
if (debugMode) {
149+
localStorage.setItem("debug", "true");
150+
}
151+
145152
// Reset query cache
146153
this.queryClient.clear();
147154

apps/client/src/utils/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const log = (...args: unknown[]) => {
22
if (localStorage.getItem("debug") === "true") {
33
// eslint-disable-next-line no-console
4-
return console.log(...args);
4+
return console.log("[LOG] ", ...args);
55
}
66
};

0 commit comments

Comments
 (0)