This commit is contained in:
薇薇安 2026-01-22 21:14:53 +08:00
parent 971d4e3a39
commit d6cdc2f055

View File

@ -27,12 +27,20 @@ const AccountSelector = ({ onChanged, currentUser, viewingUserId: propViewingUse
user_id: item.user_id
}))
setAccounts(accountsList)
// active
// activelocalStorage
const firstActive = accountsList.find((a) => String(a?.status || 'active') === 'active') || accountsList[0]
if (firstActive) {
const nextAccountId = parseInt(String(firstActive.id || ''), 10)
if (Number.isFinite(nextAccountId) && nextAccountId > 0) {
// localStorage
setCurrentAccountId(nextAccountId)
setAccountId(nextAccountId)
//
try {
window.dispatchEvent(new CustomEvent('ats:account:changed', { detail: { accountId: nextAccountId } }))
} catch (e) {
// ignore
}
}
}
})
@ -59,12 +67,20 @@ const AccountSelector = ({ onChanged, currentUser, viewingUserId: propViewingUse
user_id: item.user_id
}))
setAccounts(accountsList)
// active
// activelocalStorage
const firstActive = accountsList.find((a) => String(a?.status || 'active') === 'active') || accountsList[0]
if (firstActive) {
const nextAccountId = parseInt(String(firstActive.id || ''), 10)
if (Number.isFinite(nextAccountId) && nextAccountId > 0) {
// localStorage
setCurrentAccountId(nextAccountId)
setAccountId(nextAccountId)
//
try {
window.dispatchEvent(new CustomEvent('ats:account:changed', { detail: { accountId: nextAccountId } }))
} catch (e) {
// ignore
}
}
}
})