lucaorio / obsidian-image-gallery

A zero setup masonry image gallery for Obsidian
MIT License
186 stars 14 forks source link

Bug: sort by name doesn't work #12

Closed chrismelbourne closed 1 year ago

chrismelbourne commented 1 year ago

First off, thank you for a wonderful, useful plugin!!

Here's my little contribution :)

Currently sortby: name is broken.

Fix: Lines 125-126: Replace const refA = this._settings.sortby ? a.stat[this._settings.sortby] : a["name"].toUpperCase(); const refB = this._settings.sortby? b.stat[this._settings.sortby] : b["name"].toUpperCase();

With: const refA = (this._settings.sortby !== "name") ? a.stat[this._settings.sortby] : a["name"].toUpperCase(); const refB = (this._settings.sortby !== "name") ? b.stat[this._settings.sortby] : b["name"].toUpperCase();

Reason is that currently, if sortby: name, refA and refB will always be set to a.stat["name"] and b.stat["name"] respectively. But those properties do not exist (only ctime, mtime and size exist under .stat).

lucaorio commented 1 year ago

Hi @chrismelbourne, thanks for catching this! I just fixed the mistake. I also ended up reversing the logic a little to make it more readable. :)