Skip to content

Commit 5cfa4cc

Browse files
committed
refactor: move reverse check to grouper constructor
1 parent 3723515 commit 5cfa4cc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Query/Grouper.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Grouper {
3737

3838
/**
3939
* Whether the headings for this group should be reversed.
40+
* TODO now reverse used only in TaskGroups.toString(), shall be removed.
4041
*/
4142
public readonly reverse: boolean;
4243

@@ -46,6 +47,10 @@ export class Grouper {
4647
this.property = property;
4748
this.grouper = grouper;
4849
this.reverse = reverse;
49-
this.comparator = comparator;
50+
this.comparator = (a: Task, b: Task) => {
51+
const result = comparator(a, b);
52+
53+
return reverse ? -result : result;
54+
};
5055
}
5156
}

src/Query/TaskGroups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class TaskGroups {
110110
const grouper = this._groupers[i];
111111
const result = grouper.comparator(group1.tasks[0], group2.tasks[0]);
112112
if (result !== 0) {
113-
return grouper.reverse ? -result : result;
113+
return result;
114114
}
115115
}
116116
// identical if we reach here

0 commit comments

Comments
 (0)