@@ -6,7 +6,7 @@ import type {
66 AttemptDataWithIDAndRev ,
77} from "../results/AttemptData" ;
88import { Stats } from "../results/Stats" ;
9- import { TimerSession , allDocsResponseToTimes } from "../results/TimerSession" ;
9+ import { TimerSession } from "../results/TimerSession" ;
1010import { Controller } from "../timing/Controller" ;
1111import type { Milliseconds } from "../timing/Timer" ;
1212import { ScrambleView , type ScrambleWithEvent } from "../ui/ScrambleView" ;
@@ -36,27 +36,24 @@ const favicons: { [s: string]: string } = {
3636// TODO: Import this from "./scramble-worker"
3737export type ScrambleID = number ;
3838
39- const STORED_EVENT_TIMEOUT_MS = 15 * 60 * 1000 ;
4039const LATEST_AMOUNT = 100 ;
4140
4241export class TimerApp {
4342 private scrambleView : ScrambleView ;
4443 private statsView : StatsView ;
4544 private domElement : HTMLElement ;
46- private currentEvent : EventID ;
45+ private currentEvent : EventID = "333" ; // TODO: are there any issues with a default value here?
4746 private controller : Controller ;
48- private awaitedScrambleID : ScrambleID ;
49- private currentScramble : ScrambleWithEvent ;
47+ private awaitedScrambleID : ScrambleID | undefined ;
48+ private currentScramble : ScrambleWithEvent | undefined ;
5049 private session = new TimerSession ( ) ;
51- private remoteDB : PouchDB . Database < AttemptData > ;
50+ // private remoteDB: PouchDB.Database<AttemptData>;
5251
53- private cachedBest : number | null = null ;
54- private cachedWorst : number | null = null ;
5552 constructor ( ) {
5653 this . session . startSync ( this . onSyncChange . bind ( this ) ) ;
5754
5855 this . scrambleView = new ScrambleView ( this ) ;
59- this . statsView = new StatsView ( ( ) => this . currentEvent ) ;
56+ this . statsView = new StatsView ( ) ;
6057 this . domElement = < HTMLElement > document . getElementById ( "timer-app" ) ;
6158
6259 this . enableOffline ( ) ;
@@ -103,18 +100,21 @@ export class TimerApp {
103100 // }, 750);
104101 }
105102
106- private async getTimes ( ) : Promise < Milliseconds [ ] > {
107- const docs0 = await this . session . mostRecentAttemptsForEvent (
108- this . currentEvent ,
109- LATEST_AMOUNT ,
110- ) ;
111- console . log ( docs0 ) ;
112- const docs = await this . session . db . allDocs ( {
113- // descending: true,
114- include_docs : true ,
115- } ) ;
116- return allDocsResponseToTimes ( docs ) ;
117- }
103+ // private async getTimes(): Promise<Milliseconds[]> {
104+ // if (!this.currentEvent) {
105+ // return [];
106+ // }
107+ // const docs0 = await this.session.mostRecentAttemptsForEvent(
108+ // this.currentEvent,
109+ // LATEST_AMOUNT,
110+ // );
111+ // console.log(docs0);
112+ // const docs = await this.session.db.allDocs({
113+ // // descending: true,
114+ // include_docs: true,
115+ // });
116+ // return allDocsResponseToTimes(docs);
117+ // }
118118
119119 // Prevent a timer tap from scrolling the whole page on touch screens.
120120 private onTouchMove ( e : Event ) {
@@ -127,7 +127,7 @@ export class TimerApp {
127127 }
128128
129129 private enableOffline ( ) {
130- const infoBar = document . getElementById ( "update-bar" ) ;
130+ // const infoBar = document.getElementById("update-bar");
131131 }
132132
133133 private setInitialEvent ( ) {
@@ -238,8 +238,8 @@ export class TimerApp {
238238 event : this . currentEvent ,
239239 scramble : this . currentScramble ?. scramble ?. toString ( ) ?? "" ,
240240 } ;
241- if ( localStorage . pouchDBDeviceName ) {
242- attemptData . device = localStorage . pouchDBDeviceName ;
241+ if ( localStorage [ " pouchDBDeviceName" ] ) {
242+ attemptData . device = localStorage [ " pouchDBDeviceName" ] ;
243243 }
244244 await this . session . addNewAttempt ( attemptData ) ;
245245 }
@@ -253,7 +253,7 @@ export class TimerApp {
253253 ) . docs . reverse ( ) ;
254254 }
255255
256- async updateDisplayStats ( assumeAttemptAppended : boolean = false ) {
256+ async updateDisplayStats ( _assumeAttemptAppended : boolean = false ) {
257257 const attempts = await this . latest ( ) ;
258258 const times = attempts . map ( ( attempt ) => attempt . totalResultMs ) ;
259259 const numAttempts = ( await this . session . db . info ( ) ) . doc_count - 1 ;
0 commit comments