From 89c74b905416197c3890e6315f4bd9668bfa9358 Mon Sep 17 00:00:00 2001 From: Luke Leppan Date: Mon, 12 Jul 2021 14:47:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20#15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/manager.ts | 14 ++++++++++++++ src/status/manager.ts | 16 +++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/data/manager.ts b/src/data/manager.ts index 44615fb..8162202 100644 --- a/src/data/manager.ts +++ b/src/data/manager.ts @@ -32,6 +32,12 @@ export interface TodayCounts { sentences: number; } +export interface TotalCounts { + words: number; + characters: number; + sentences: number; +} + export class DataManager { private vault: Vault; private metadataCache: MetadataCache; @@ -171,6 +177,14 @@ export class DataManager { return this.todayCounts; } + getTotalCounts(): TotalCounts { + return { + words: this.history[this.today].totalWords, + characters: this.history[this.today].totalCharacters, + sentences: this.history[this.today].totalSentences, + }; + } + async updateFromFile() { this.history = Object.assign( JSON.parse(await this.vault.adapter.read(".vault-stats")) diff --git a/src/status/manager.ts b/src/status/manager.ts index 89e7d11..655432e 100644 --- a/src/status/manager.ts +++ b/src/status/manager.ts @@ -65,13 +65,13 @@ export class BarManager { newText = newText + getSentenceCount(text); break; case 3: - newText = newText + this.dataManager.getTodayCounts().words; + newText = newText + this.dataManager.getTotalCounts().words; break; case 4: - newText = newText + this.dataManager.getTodayCounts().characters; + newText = newText + this.dataManager.getTotalCounts().characters; break; case 5: - newText = newText + this.dataManager.getTodayCounts().sentences; + newText = newText + this.dataManager.getTotalCounts().sentences; break; case 6: newText = newText + this.dataCollector.getTotalFileCount(); @@ -92,7 +92,7 @@ export class BarManager { this.statusBar.displayText(newText); } - updateAltStatusBar(): void { + async updateAltStatusBar(): Promise { let newText = ""; const expression: Expression = parse(this.settings.statusBarAltQuery); if (this.settings.collectStats) { @@ -118,13 +118,15 @@ export class BarManager { newText = newText + getSentenceCount(""); break; case 3: - newText = newText + this.dataManager.getTodayCounts().words; + newText = newText + (await this.dataCollector.getTotalWordCount()); break; case 4: - newText = newText + this.dataManager.getTodayCounts().characters; + newText = + newText + (await this.dataCollector.getTotalCharacterCount()); break; case 5: - newText = newText + this.dataManager.getTodayCounts().sentences; + newText = + newText + (await this.dataCollector.getTotalSentenceCount()); break; case 6: newText = newText + this.dataCollector.getTotalFileCount();