This commit is contained in:
Luke Leppan 2021-07-12 14:47:37 +02:00
parent f17d71342a
commit 89c74b9054
2 changed files with 23 additions and 7 deletions

View file

@ -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"))

View file

@ -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<void> {
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();