diff --git a/src/compiler.ts b/src/compiler.ts
index 5990c08..659b8e5 100644
--- a/src/compiler.ts
+++ b/src/compiler.ts
@@ -171,7 +171,11 @@ export class ColorCompiler {
folder: TFolder,
fileExplorer = this.getFileExplorerView()
) {
- if (!fileExplorer) {
+ if (
+ !fileExplorer ||
+ !fileExplorer.containerEl ||
+ fileExplorer.containerEl.getAttr("data-type") === "undefined"
+ ) {
console.warn("File explorer view not found");
return;
}
@@ -181,10 +185,10 @@ export class ColorCompiler {
);
let timeout = 0;
- const maxTimeout = this.getTimeout() || 50;
+ const maxTimeout = this.getTimeout();
while (treeItems.length === 0 && timeout < maxTimeout) {
// biome-ignore lint/correctness/noUndeclaredVariables: sleep is a global function in obsidian
- await sleep(100);
+ await sleep(10);
treeItems = fileExplorer.containerEl.querySelectorAll(
`.tree-item.nav-folder > .nav-folder-title[data-path="${folder.path}"]`
);
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index 252fd03..7520ef3 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -49,7 +49,7 @@
"explain": "Globally, the plugin will loop until it found the node at {{- code}}.",
"invalid": "Please set a valid number",
"mobile": "Mobile",
- "mobileDesc": "It will take {{- calc}}s until it will stop searching node.",
+ "mobileDesc": "It will take {{- calc}}s until it will stop searching node. Also, it allows to wait for the explorer to be ready.",
"reload": "Requires reloading Obsidian or the plugin.",
"title": "Timeout"
},
diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json
index c7237d3..60518ea 100644
--- a/src/i18n/locales/fr.json
+++ b/src/i18n/locales/fr.json
@@ -49,7 +49,7 @@
"explain": "Globalement, le plugin effectuera une boucle jusqu'à ce qu'il trouve le nœud à {{- code}}.",
"invalid": "Please set a valid number",
"mobile": "Mobile",
- "mobileDesc": "Il faudra {{- calc}} secondes avant que la recherche du nœud s'arrête.",
+ "mobileDesc": "Il faudra {{- calc}} secondes avant que la recherche du nœud s'arrête. Cela permet aussi d'attendre que l'explorateur soit prêt.",
"reload": "Nécessite un rechargement d'Obsidian ou du plugin.",
"title": "Timeout"
},
diff --git a/src/main.ts b/src/main.ts
index fcd3b70..aae25e7 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -55,6 +55,8 @@ export default class SimpleColoredFolder extends Plugin {
);
}
const folders = this.compiler.getFolder();
+ // biome-ignore lint/correctness/noUndeclaredVariables: sleep is a global function in obsidian
+ if (this.app.isMobile) await sleep(this.settings.maxTimeout.mobile);
await this.compiler.injectDataPath(folders);
await this.compiler.injectStyles(true, folders);
this.app.vault.on("create", async (file) => {
diff --git a/src/settings.ts b/src/settings.ts
index 76648b5..93a68cb 100644
--- a/src/settings.ts
+++ b/src/settings.ts
@@ -51,7 +51,7 @@ export class SimpleColoredFolderSettingTab extends PluginSettingTab {
const timeOutdesc = sanitizeHTMLToDom(
`${i18next.t("settings.timeout.desc")}
${i18next.t("settings.timeout.explain", {
- code: "timeout*100ms",
+ code: "timeout*10ms",
})}
${i18next.t("settings.timeout.reload")}`
);
@@ -65,7 +65,7 @@ export class SimpleColoredFolderSettingTab extends PluginSettingTab {
.setDesc(
sanitizeHTMLToDom(
`${i18next.t("settings.timeout.mobileDesc", {
- calc: `${(this.settings.maxTimeout.mobile * 100) / 1000}s`,
+ calc: `${(this.settings.maxTimeout.mobile * 10) / 1000}s`,
})}`
)
)
@@ -95,7 +95,7 @@ export class SimpleColoredFolderSettingTab extends PluginSettingTab {
.setDesc(
sanitizeHTMLToDom(
`${i18next.t("settings.timeout.mobileDesc", {
- calc: `${(this.settings.maxTimeout.desktop * 100) / 1000}s`,
+ calc: `${(this.settings.maxTimeout.desktop * 10) / 1000}s`,
})}`
)
)