Refactor: Move some functions from modules to services

This commit is contained in:
vorotamoroz
2026-02-12 06:27:29 +00:00
parent b1bba7685e
commit 787627a156
11 changed files with 75 additions and 81 deletions
@@ -0,0 +1,33 @@
import { getPathFromTFile } from "@/common/utils";
import { InjectableVaultService } from "@/lib/src/services/implements/injectable/InjectableVaultService";
import type { ObsidianServiceContext } from "@/lib/src/services/implements/obsidian/ObsidianServiceContext";
import type { FilePath } from "@/lib/src/common/types";
declare module "obsidian" {
interface DataAdapter {
insensitive?: boolean;
}
}
// InjectableVaultService
export class ObsidianVaultService extends InjectableVaultService<ObsidianServiceContext> {
vaultName(): string {
return this.context.app.vault.getName();
}
getActiveFilePath(): FilePath | undefined {
const file = this.context.app.workspace.getActiveFile();
if (file) {
return getPathFromTFile(file);
}
return undefined;
}
isStorageInsensitive(): boolean {
return this.context.app.vault.adapter.insensitive ?? true;
}
override shouldCheckCaseInsensitively(): boolean {
// If the storage is insensitive, always return false, that because no need to check again.
if (this.isStorageInsensitive()) return false;
return super.shouldCheckCaseInsensitively(); // Check the setting
}
}