Skip to content

Commit

Permalink
fix(List/Matrix View): 🐛 Sort by lowerCase (fix #294)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jan 29, 2022
1 parent beb98b2 commit 728929e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
13 changes: 5 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36790,14 +36790,11 @@ class MatrixView extends obsidian.ItemView {
this.sortItemsAlpha = (a, b) => {
var _a, _b;
const { sortByNameShowAlias, alphaSortAsc } = this.plugin.settings;
return (sortByNameShowAlias ? a.to : (_a = a.alt) !== null && _a !== void 0 ? _a : a.to) <
(sortByNameShowAlias ? b.to : (_b = b.alt) !== null && _b !== void 0 ? _b : b.to)
? alphaSortAsc
? -1
: 1
: alphaSortAsc
? 1
: -1;
const aToSort = (sortByNameShowAlias ? a.to : (_a = a.alt) !== null && _a !== void 0 ? _a : a.to).toLowerCase();
const bToSort = (sortByNameShowAlias ? b.to : (_b = b.alt) !== null && _b !== void 0 ? _b : b.to).toLowerCase();
const less = alphaSortAsc ? -1 : 1;
const more = alphaSortAsc ? 1 : -1;
return aToSort < bToSort ? less : more;
};
this.plugin = plugin;
this.db = new Debugger(plugin);
Expand Down
17 changes: 8 additions & 9 deletions src/Views/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { getDVApi, linkClass } from "../Utils/ObsidianUtils";

export default class MatrixView extends ItemView {
plugin: BCPlugin;
private view: Matrix | Lists;
private view: MLContainer;
matrixQ: boolean;
db: Debugger;

Expand Down Expand Up @@ -151,14 +151,13 @@ export default class MatrixView extends ItemView {

sortItemsAlpha = (a: internalLinkObj, b: internalLinkObj) => {
const { sortByNameShowAlias, alphaSortAsc } = this.plugin.settings;
return (sortByNameShowAlias ? a.to : a.alt ?? a.to) <
(sortByNameShowAlias ? b.to : b.alt ?? b.to)
? alphaSortAsc
? -1
: 1
: alphaSortAsc
? 1
: -1;
const aToSort = (sortByNameShowAlias ? a.to : a.alt ?? a.to).toLowerCase();
const bToSort = (sortByNameShowAlias ? b.to : b.alt ?? b.to).toLowerCase();

const less = alphaSortAsc ? -1 : 1;
const more = alphaSortAsc ? 1 : -1;

return aToSort < bToSort ? less : more;
};

getHierSquares(userHiers: UserHier[], currFile: TFile): SquareProps[][] {
Expand Down

0 comments on commit 728929e

Please sign in to comment.