Fix splice(-1,1) removing last user when logged-in user not found

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 13:52:08 +08:00
parent 3db725e52c
commit 9acd722929
2 changed files with 35 additions and 3 deletions

View File

@@ -127,7 +127,9 @@ export const useAcctMgmtStore = defineStore('acctMgmtStore', {
const loginStore = useLoginStore();
const loginUserData:User = loginStore.userData;
const foundLoginUserIndex = fetchedUserList.findIndex(user => user.username === loginUserData.username);
fetchedUserList.unshift(fetchedUserList.splice(foundLoginUserIndex, 1)[0]);
if (foundLoginUserIndex !== -1) {
fetchedUserList.unshift(fetchedUserList.splice(foundLoginUserIndex, 1)[0]);
}
return fetchedUserList;
},
/**