| 682 | if (r.hasIncRem && r.currentIncPriority !== null) allPriorities.push(r.currentIncPriority); |
| 683 | if (r.hasCardPriority && r.currentCardPriority !== null) allPriorities.push(r.currentCardPriority); |
| 684 | }); |
| 685 | |
| 686 | const minCurrent = Math.min(...allPriorities); |
| 687 | const maxCurrent = Math.max(...allPriorities); |
| 688 | const currentRange = maxCurrent - minCurrent || 1; |
| 689 | |
| 690 | const newRange = spreadEnd - spreadStart; |
| 691 | console.log(' - Adjust: current range', currentRange, 'new range:', newRange); |
| 692 | |
| 693 | updatedRems = updatedRems.map(rem => { |
| 694 | if (isInScope(rem) && rem.isChecked) { |
| 695 | const newIncPriority = (rem.hasIncRem && rem.currentIncPriority !== null) |
| 696 | ? Math.round(spreadStart + ((rem.currentIncPriority - minCurrent) / currentRange) * newRange) |
| 697 | : null; |
| 698 | const newCardPriority = (rem.hasCardPriority && rem.currentCardPriority !== null) |
| 699 | ? Math.round(spreadStart + ((rem.currentCardPriority - minCurrent) / currentRange) * newRange) |
| 700 | : null; |