diff --git a/Makefile b/Makefile index 274c3d3..bc6334b 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,5 @@ start-server: build-client clean: docker compose down - rm -r server/public/ client/dist/ + -rm -r server/public/ client/dist/ + diff --git a/client/src/state.ts b/client/src/state.ts index 13e3312..67c0955 100644 --- a/client/src/state.ts +++ b/client/src/state.ts @@ -26,6 +26,7 @@ class AppState { tracks: Array state: State user?: LoggedInUser + source?: EventSource constructor() { this.tracks = new Array @@ -79,16 +80,22 @@ class AppState { window.location = window.location }) window.addEventListener('beforeunload', () => source.close()) + this.source = source } async repopulate() { + if (!this.user) { + this.tracks = [] + return + } this.state = State.Fetching this.tracks = await Track.fetchAll() + this.source?.close() + this.streamUpdatesFromServer() + this.state = State.Fetched } async populate() { if (this.state != State.Unfetched) return await this.repopulate() - this.streamUpdatesFromServer() - this.state = State.Fetched } async taskCompleted(track: Track, date: Date): Promise { const query = dateQuery(date) diff --git a/client/src/track.ts b/client/src/track.ts index 83947a3..9893eca 100644 --- a/client/src/track.ts +++ b/client/src/track.ts @@ -1,4 +1,5 @@ import { error } from "./error" +import { Tick, ITick } from './ticks' export interface ITrack { id?: number @@ -97,4 +98,4 @@ export class Track implements ITrack { } return [] } -} \ No newline at end of file +} diff --git a/client/src/views/Login.vue b/client/src/views/Login.vue index 2ef2efe..9f21ab0 100644 --- a/client/src/views/Login.vue +++ b/client/src/views/Login.vue @@ -1,6 +1,7 @@