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
15
main.ts
15
main.ts
|
@ -86,7 +86,15 @@ export default class NovelWordCountPlugin extends Plugin {
|
||||||
|
|
||||||
public async initialize() {
|
public async initialize() {
|
||||||
await this.refreshAllCounts();
|
await this.refreshAllCounts();
|
||||||
|
|
||||||
|
try {
|
||||||
await this.updateDisplayedCounts();
|
await this.updateDisplayedCounts();
|
||||||
|
} catch (err) {
|
||||||
|
// File Explorer pane may not be loaded yet
|
||||||
|
setTimeout(() => {
|
||||||
|
this.updateDisplayedCounts();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateDisplayedCounts() {
|
public async updateDisplayedCounts() {
|
||||||
|
@ -151,13 +159,6 @@ export default class NovelWordCountPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleEvents(): void {
|
private handleEvents(): void {
|
||||||
this.registerEvent(
|
|
||||||
this.app.workspace.on("file-open", async () => {
|
|
||||||
await this.loadSettings();
|
|
||||||
await this.updateDisplayedCounts();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
this.app.vault.on("modify", async (file) => {
|
this.app.vault.on("modify", async (file) => {
|
||||||
await this.fileHelper.updateFileCounts(
|
await this.fileHelper.updateFileCounts(
|
||||||
|
|
Loading…
Reference in New Issue