Skip to content

Commit 1019484

Browse files
committed
#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
1 parent 6085be8 commit 1019484

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/main.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,23 @@ export default class CustomSortPlugin
178178

179179
checkFileExplorerIsAvailableAndPatchable(logWarning: boolean = true): FileExplorerView | undefined {
180180
let fileExplorerView: FileExplorerView | undefined = this.getFileExplorer()
181-
if (fileExplorerView
182-
&& typeof fileExplorerView.createFolderDom === 'function'
183-
&& typeof fileExplorerView.requestSort === 'function') {
184-
return fileExplorerView
185-
} else {
186-
// Various scenarios when File Explorer was turned off (e.g. by some other plugin)
187-
if (logWarning) {
188-
this.logWarningFileExplorerNotAvailable()
181+
if (fileExplorerView && typeof fileExplorerView.requestSort === 'function') {
182+
// The plugin integration points changed with Obsidian 1.6.0 hence the patchability-check should also be Obsidian version aware
183+
if (requireApiVersion && requireApiVersion("1.6.0")) {
184+
if (typeof fileExplorerView.getSortedFolderItems === 'function') {
185+
return fileExplorerView
186+
}
187+
} else { // Obsidian versions prior to 1.6.0
188+
if (typeof fileExplorerView.createFolderDom === 'function') {
189+
return fileExplorerView
190+
}
189191
}
190-
return undefined
191192
}
193+
// Various scenarios when File Explorer was turned off (e.g. by some other plugin)
194+
if (logWarning) {
195+
this.logWarningFileExplorerNotAvailable()
196+
}
197+
return undefined
192198
}
193199

194200
logWarningFileExplorerNotAvailable() {

src/types/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ declare module 'obsidian' {
5151

5252
export interface FileExplorerView extends View {
5353
createFolderDom(folder: TFolder): FileExplorerFolder;
54+
getSortedFolderItems(sortedFolder: TFolder): any[];
5455

5556
requestSort(): void;
5657

0 commit comments

Comments
 (0)