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:
co-authored by
Cursor
parent
1e9f6481b0
commit
be9e7da424
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user