Fix NaN comparator skipping tiebreaker in project sorting
When both projects lack timestamps and have no threads, getProjectSortTimestamp returns NEGATIVE_INFINITY for both. Subtracting NEGATIVE_INFINITY - NEGATIVE_INFINITY yields NaN, and since NaN !== 0 is true, the comparator returned NaN instead of falling through to the name/id tiebreaker. Add Number.isNaN guard to the condition.
This commit is contained in:
1 file changed
+1
-1
@@ -270,7 +270,7 @@ export function sortProjectsForSidebar<TProject extends SidebarProject, TThread
|
||||
const byTimestamp =
|
||||
getProjectSortTimestamp(right, threadsByProjectId.get(right.id) ?? [], sortOrder) -
|
||||
getProjectSortTimestamp(left, threadsByProjectId.get(left.id) ?? [], sortOrder);
|
||||
if (byTimestamp !== 0) return byTimestamp;
|
||||
if (byTimestamp !== 0 && !Number.isNaN(byTimestamp)) return byTimestamp;
|
||||
return left.name.localeCompare(right.name) || left.id.localeCompare(right.id);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user