Bugfix: pass DataManager to BarManager constructor

Before this patch, the BarManager constructor created a new DataManager instance,
leading to this.dataManager != this.barManager.dataManager. This led to effects such as
daily counts not updating in some circumstances, while total counts did.
This commit is contained in:
Leo Yao 2022-05-25 10:55:11 -04:00 committed by GitHub
parent 60ea70cfff
commit 640d920f8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View file

@ -28,20 +28,20 @@ export default class BetterWordCount extends Plugin {
let statusBarEl = this.addStatusBarItem(); let statusBarEl = this.addStatusBarItem();
this.statusBar = new StatusBar(statusBarEl); this.statusBar = new StatusBar(statusBarEl);
this.barManager = new BarManager(
this.statusBar,
this.settings,
this.app.vault,
this.app.metadataCache
);
if (this.settings.collectStats) {
this.dataManager = new DataManager( this.dataManager = new DataManager(
this.app.vault, this.app.vault,
this.app.metadataCache, this.app.metadataCache,
this.settings this.settings
); );
}
this.barManager = new BarManager(
this.statusBar,
this.settings,
this.app.vault,
this.app.metadataCache,
this.dataManager
);
this.registerEvent( this.registerEvent(
this.app.workspace.on("active-leaf-change", this.activeLeafChange, this) this.app.workspace.on("active-leaf-change", this.activeLeafChange, this)

View file

@ -25,13 +25,14 @@ export class BarManager {
statusBar: StatusBar, statusBar: StatusBar,
settings: BetterWordCountSettings, settings: BetterWordCountSettings,
vault: Vault, vault: Vault,
metadataCache: MetadataCache metadataCache: MetadataCache,
dataManager: DataManager
) { ) {
this.statusBar = statusBar; this.statusBar = statusBar;
this.settings = settings; this.settings = settings;
this.vault = vault; this.vault = vault;
this.dataCollector = new DataCollector(vault, metadataCache, settings); this.dataCollector = new DataCollector(vault, metadataCache, settings);
this.dataManager = new DataManager(vault, metadataCache, settings); this.dataManager = dataManager;
this.deboucer = debounce( this.deboucer = debounce(
(text: string) => this.updateStatusBar(text), (text: string) => this.updateStatusBar(text),
20, 20,