mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Use stable card IDs to break equal effective-rank ties across fetches and clients. Preserve explicit zero ranks and normal list-position fallback. Cover metadata edits and refreshes in Chromium. Thanks to xet7 !
13 lines
445 B
JavaScript
13 lines
445 B
JavaScript
'use strict';
|
|
|
|
// List positions can repeat across a board, and explicit backlog ranks need
|
|
// not be unique. A stable ID tie-breaker keeps refreshes and clients aligned.
|
|
function compareScrumCards(a, b) {
|
|
const rank = card => card.scrum?.backlogRank ?? card.sort ?? 0;
|
|
const difference = rank(a) - rank(b);
|
|
if (difference) return difference;
|
|
return a._id < b._id ? -1 : a._id > b._id ? 1 : 0;
|
|
}
|
|
|
|
module.exports = { compareScrumCards };
|