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

View file

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