#160 - compatibility with Obsidian 1.7.2

- the fileExplorer patchability check made smarter and version-dependent
- the plugin-integration-point support required by Obsidian 1.7.2 has been already incorporated in the plugin earlier on, for 1.6.0 Obsidian release
This commit is contained in:
SebastianMC 2024-09-20 18:53:50 +02:00
parent 6085be8c60
commit 1019484935
2 changed files with 16 additions and 9 deletions

View File

@ -178,18 +178,24 @@ export default class CustomSortPlugin
checkFileExplorerIsAvailableAndPatchable(logWarning: boolean = true): FileExplorerView | undefined {
let fileExplorerView: FileExplorerView | undefined = this.getFileExplorer()
if (fileExplorerView
&& typeof fileExplorerView.createFolderDom === 'function'
&& typeof fileExplorerView.requestSort === 'function') {
if (fileExplorerView && typeof fileExplorerView.requestSort === 'function') {
// The plugin integration points changed with Obsidian 1.6.0 hence the patchability-check should also be Obsidian version aware
if (requireApiVersion && requireApiVersion("1.6.0")) {
if (typeof fileExplorerView.getSortedFolderItems === 'function') {
return fileExplorerView
} else {
}
} else { // Obsidian versions prior to 1.6.0
if (typeof fileExplorerView.createFolderDom === 'function') {
return fileExplorerView
}
}
}
// Various scenarios when File Explorer was turned off (e.g. by some other plugin)
if (logWarning) {
this.logWarningFileExplorerNotAvailable()
}
return undefined
}
}
logWarningFileExplorerNotAvailable() {
const msg = `custom-sort v${this.manifest.version}: failed to locate File Explorer. The 'Files' core plugin can be disabled.\n`

View File

@ -51,6 +51,7 @@ declare module 'obsidian' {
export interface FileExplorerView extends View {
createFolderDom(folder: TFolder): FileExplorerFolder;
getSortedFolderItems(sortedFolder: TFolder): any[];
requestSort(): void;