Skip to content

Commit

Permalink
Bugfix for #131
Browse files Browse the repository at this point in the history
Obsidian introduced breaking changes around File Explorer JS structure which prevented this custom-sort plugin from working.
- fix backward compatible with versions earlier that 1.5.4
- version bump before release
  • Loading branch information
SebastianMC committed Feb 9, 2024
1 parent 9f4008c commit 53b5895
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
4 changes: 0 additions & 4 deletions README.md
@@ -1,7 +1,3 @@
| :exclamation: For users of Obsidian insider build versions (1.5.4 and up)|
|----|
| 1.5.4 insider build of Obsidian introduced breaking changes in JS code of File Explorer which prevents this custom-sort plugin from working. Please refrain from updating Obsidian until the code of custom-sort is updated. |

> > This is a simple version of README which highlights the **basic scenario and most commonly used feature**
>
> The [long and much more detailed advanced-README.md is here](https://github.com/SebastianMC/obsidian-custom-sort/blob/master/docs/advanced-README.md)
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
@@ -1,7 +1,7 @@
{
"id": "custom-sort",
"name": "Custom File Explorer sorting",
"version": "2.1.5",
"version": "2.1.7",
"minAppVersion": "0.16.2",
"description": "Allows for manual and automatic, config-driven reordering and sorting of files and folders in File Explorer",
"author": "SebastianMC",
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "obsidian-custom-sort",
"version": "2.1.5",
"version": "2.1.7",
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/custom-sort/custom-sort.ts
Expand Up @@ -685,7 +685,7 @@ export const determineBookmarksOrderIfNeeded = (folderItems: Array<FolderItemFor
}

export const folderSort = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext) {
let fileExplorer = this.fileExplorer
let fileExplorerView = this.fileExplorer ?? this.view // this.view replaces the former since 1.5.4 insider build

// shallow copy of groups and expand folder-specific macros on them
sortingSpec.groupsShadow = sortingSpec.groups?.map((group) => Object.assign({} as CustomSortGroup, group))
Expand All @@ -710,12 +710,12 @@ export const folderSort = function (sortingSpec: CustomSortSpec, ctx: Processing
determineBookmarksOrderIfNeeded(folderItems, sortingSpec, ctx.bookmarksPluginInstance)
}

const comparator: SorterFn = getComparator(sortingSpec, fileExplorer.sortOrder)
const comparator: SorterFn = getComparator(sortingSpec, fileExplorerView.sortOrder)

folderItems.sort(comparator)

const items = folderItems
.map((item: FolderItemForSorting) => fileExplorer.fileItems[item.path])
.map((item: FolderItemForSorting) => fileExplorerView.fileItems[item.path])

if (requireApiVersion && requireApiVersion("0.15.0")) {
this.vChildren.setChildren(items);
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Expand Up @@ -39,5 +39,6 @@
"2.1.2": "0.16.2",
"2.1.3": "0.16.2",
"2.1.4": "0.16.2",
"2.1.5": "0.16.2"
"2.1.5": "0.16.2",
"2.1.7": "0.16.2"
}

0 comments on commit 53b5895

Please sign in to comment.