#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,17 +178,23 @@ export default class CustomSortPlugin
checkFileExplorerIsAvailableAndPatchable(logWarning: boolean = true): FileExplorerView | undefined { checkFileExplorerIsAvailableAndPatchable(logWarning: boolean = true): FileExplorerView | undefined {
let fileExplorerView: FileExplorerView | undefined = this.getFileExplorer() let fileExplorerView: FileExplorerView | undefined = this.getFileExplorer()
if (fileExplorerView if (fileExplorerView && typeof fileExplorerView.requestSort === 'function') {
&& typeof fileExplorerView.createFolderDom === 'function' // The plugin integration points changed with Obsidian 1.6.0 hence the patchability-check should also be Obsidian version aware
&& typeof fileExplorerView.requestSort === 'function') { if (requireApiVersion && requireApiVersion("1.6.0")) {
return fileExplorerView if (typeof fileExplorerView.getSortedFolderItems === 'function') {
} else { return fileExplorerView
// Various scenarios when File Explorer was turned off (e.g. by some other plugin) }
if (logWarning) { } else { // Obsidian versions prior to 1.6.0
this.logWarningFileExplorerNotAvailable() if (typeof fileExplorerView.createFolderDom === 'function') {
return fileExplorerView
}
} }
return undefined
} }
// Various scenarios when File Explorer was turned off (e.g. by some other plugin)
if (logWarning) {
this.logWarningFileExplorerNotAvailable()
}
return undefined
} }
logWarningFileExplorerNotAvailable() { logWarningFileExplorerNotAvailable() {

View File

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