Skip to content

Commit

Permalink
refactor: Change results graph & save fatigue data
Browse files Browse the repository at this point in the history
  • Loading branch information
CaedenPH committed Aug 23, 2024
1 parent c5464c1 commit f58d7b4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Binary file modified src/assets/results_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function loadConfig(): Promise<Config> {
* @param config
* @param startNow Called from restart. Bypasses sleep data
*/
export async function startUp(config: Config | null = null, startNow: boolean = false) {
export async function startUp(config: Config | null = null, startNowData: Record<string, any> | false = false) {
if (config === null) {
config = await loadConfig();
if (config.error) throw new Error(config.reason);
Expand Down Expand Up @@ -81,10 +81,10 @@ export async function startUp(config: Config | null = null, startNow: boolean =

// Display the home page
const startPage = new StartPage(config, app, graphicsManager);
if (!startNow) await startPage.displayHomePage();
if (startNowData == false) await startPage.displayHomePage();

// Display start page
const sleepData = await startPage.start(startNow);
const sleepData = await startPage.start(startNowData);
if (!sleepData) throw new Error("No sleep data");

// Game phase - called after start button is clicked
Expand Down
4 changes: 2 additions & 2 deletions src/routes/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class ProcessResultsPage {
Date/time: ${data._date}
Location: ${data.location.normalizedLocation}
Status: ${data.status}
Test duration: ${data.testDuration}s`, {
Test duration: ${data.testDuration/60}s`, {
fontFamily: "Trebuchet",
fontSize: 18,
fill: 0xffffff,
Expand Down Expand Up @@ -320,7 +320,7 @@ export class ProcessResultsPage {
restartTestButtonContainer.on("pointerdown", () => {
// TODO: Send back to home page
this.app.destroy();
startUp(config, true);
startUp(config, data.sleepData);
});

const homeButton = this.ui.createButton(
Expand Down
4 changes: 2 additions & 2 deletions src/routes/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ private async confirmSleepData(sleepData: { [key: string]: any }): Promise<boole
* TODO: Seperate pages better
* @returns {Promise<SleepData>} The test data
*/
public async start(skipToDisplay: boolean): Promise<SleepData | false> {
public async start(sleepData: Record<string, any> | false): Promise<SleepData | false> {
if (process.env.NODE_ENV === "development") return {fatigueLevel: -1};

if (skipToDisplay) {
if (sleepData != false) {
await this.displayReadyDemo(Infinity);
return {fatigueLevel: 1};
}
Expand Down

0 comments on commit f58d7b4

Please sign in to comment.