feat(wallets): pin the active wallet to the top of the list

Make "is the active wallet" the primary sort key so the current wallet always
stays at the top regardless of the chosen sort/direction; the remaining wallets
sort by the selected key underneath it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-11 16:49:05 -05:00
parent d549127e41
commit 1d3a919ac6

View File

@@ -155,7 +155,10 @@ public:
default: sortVal[k] = pr.createdEpoch; break; // 0 = date created
}
}
auto isActive = [&](std::size_t i) { return s_rows[i].inDatadir && s_rows[i].fileName == active; };
std::stable_sort(s_order.begin(), s_order.end(), [&](std::size_t a, std::size_t b) {
const bool aa = isActive(a), ba = isActive(b);
if (aa != ba) return aa; // the active wallet is always pinned to the top
return s_sortDesc ? sortVal[a] > sortVal[b] : sortVal[a] < sortVal[b];
});
}