Main Menu: Fix accounts appearing at the bottom (#5915)
This commit is contained in:
parent
9fda32d1a7
commit
b645f9460c
@ -37,6 +37,10 @@ const AccountMenuItems = ({
|
|||||||
const currentCount = getCurrentProdAccountCount();
|
const currentCount = getCurrentProdAccountCount();
|
||||||
const maxCount = getCurrentMaxAccountCount();
|
const maxCount = getCurrentMaxAccountCount();
|
||||||
|
|
||||||
|
const currentAccountInfo = useMemo(() => {
|
||||||
|
return Object.values(accounts).find((account) => account.userId === currentUser.id);
|
||||||
|
}, [accounts, currentUser.id]);
|
||||||
|
|
||||||
const shouldShowLimit = currentCount >= maxCount;
|
const shouldShowLimit = currentCount >= maxCount;
|
||||||
|
|
||||||
const handleLimitClick = useLastCallback(() => {
|
const handleLimitClick = useLastCallback(() => {
|
||||||
@ -65,15 +69,16 @@ const AccountMenuItems = ({
|
|||||||
}, [accounts, currentCount, totalLimit]);
|
}, [accounts, currentCount, totalLimit]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div>
|
||||||
{Object.entries(accounts || {})
|
{Object.entries(accounts || {})
|
||||||
.sort(([, account]) => (account.userId === currentUser.id ? -1 : 1))
|
.sort(([, account]) => (account.userId === currentUser.id ? -1 : 1))
|
||||||
.map(([slot, account], index, arr) => {
|
.map(([slot, account], index, arr) => {
|
||||||
|
const isSameServer = account.isTest === currentAccountInfo?.isTest;
|
||||||
const mockUser: CustomPeer = {
|
const mockUser: CustomPeer = {
|
||||||
title: [account.firstName, account.lastName].filter(Boolean).join(' '),
|
title: [account.firstName, account.lastName].filter(Boolean).join(' '),
|
||||||
isCustomPeer: true,
|
isCustomPeer: true,
|
||||||
peerColorId: account.color,
|
peerColorId: account.color,
|
||||||
emojiStatusId: account.emojiStatusId,
|
emojiStatusId: isSameServer ? account.emojiStatusId : undefined,
|
||||||
isPremium: account.isPremium,
|
isPremium: account.isPremium,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,7 +116,7 @@ const AccountMenuItems = ({
|
|||||||
{lang('MenuAddAccount')}
|
{lang('MenuAddAccount')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user