Remove unnecessary event handler; wait up to 1 second for File Explorer pane to load on initialization
This commit is contained in:
parent
5a51033da8
commit
cea1cc5760
17
main.ts
17
main.ts
|
@ -86,7 +86,15 @@ export default class NovelWordCountPlugin extends Plugin {
|
|||
|
||||
public async initialize() {
|
||||
await this.refreshAllCounts();
|
||||
await this.updateDisplayedCounts();
|
||||
|
||||
try {
|
||||
await this.updateDisplayedCounts();
|
||||
} catch (err) {
|
||||
// File Explorer pane may not be loaded yet
|
||||
setTimeout(() => {
|
||||
this.updateDisplayedCounts();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public async updateDisplayedCounts() {
|
||||
|
@ -151,13 +159,6 @@ export default class NovelWordCountPlugin extends Plugin {
|
|||
}
|
||||
|
||||
private handleEvents(): void {
|
||||
this.registerEvent(
|
||||
this.app.workspace.on("file-open", async () => {
|
||||
await this.loadSettings();
|
||||
await this.updateDisplayedCounts();
|
||||
})
|
||||
);
|
||||
|
||||
this.registerEvent(
|
||||
this.app.vault.on("modify", async (file) => {
|
||||
await this.fileHelper.updateFileCounts(
|
||||
|
|
Loading…
Reference in New Issue