feat(web): pin the current user to the top of admin user list (#18345)

This commit is contained in:
chanx
2026-08-17 11:20:15 +08:00
committed by GitHub
parent c3b977f7b6
commit ddff47e7cb

View File

@@ -449,8 +449,27 @@ function AdminUserManagement() {
],
);
// Pin the current user to the top of the list
const orderedUsersList = useMemo(() => {
if (!usersList) {
return EMPTY_DATA;
}
const currentUserIndex = usersList.findIndex(
(user) => user.email === userInfo?.email,
);
if (currentUserIndex <= 0) {
return usersList;
}
const rest = usersList.filter((_, index) => index !== currentUserIndex);
return [usersList[currentUserIndex], ...rest];
}, [usersList, userInfo?.email]);
const table = useReactTable({
data: usersList ?? EMPTY_DATA,
data: orderedUsersList,
columns: columnDefs,
globalFilterFn,