Fix portfolio move-to-top and put category beside the date.

Bump sort_order above the page leader instead of swapping, and align category left with date right on one meta row.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-23 15:12:45 +03:30
co-authored by Cursor
parent 1e9f6481b0
commit be9e7da424
4 changed files with 38 additions and 33 deletions
+9 -13
View File
@@ -177,23 +177,19 @@ export function PortfolioListPage() {
if (index === 0 && currentPage === 1) return
const current = portfolios[index]
// Jump above the current page leader (highest sort_order wins). Avoids
// fragile swaps that no-op when ties / secondary date order disagree.
const leader = portfolios[0]
const nextSortOrder =
index === 0
? current.sortOrder + 1
: Math.max(leader.sortOrder, current.sortOrder) + 1
setMovingUpId(id)
setError('')
try {
if (index === 0) {
await updatePortfolio(current.id, { sortOrder: current.sortOrder + 1 })
} else {
const previous = portfolios[index - 1]
if (current.sortOrder === previous.sortOrder) {
await updatePortfolio(current.id, { sortOrder: previous.sortOrder + 1 })
} else {
await Promise.all([
updatePortfolio(current.id, { sortOrder: previous.sortOrder }),
updatePortfolio(previous.id, { sortOrder: current.sortOrder }),
])
}
}
await updatePortfolio(current.id, { sortOrder: nextSortOrder })
showToast(t('portfolio.list.toast.movedUp'), 'success')
await loadPortfolios(currentPage)
} catch (err) {