Multi-Account: Fix test server handling (#5889)
This commit is contained in:
parent
8c4431d57c
commit
a922873612
@ -42,6 +42,7 @@ type StateProps = Pick<GlobalState, (
|
||||
)> & {
|
||||
language?: string;
|
||||
phoneCodeList: ApiCountryCode[];
|
||||
isTestServer?: boolean;
|
||||
};
|
||||
|
||||
const MIN_NUMBER_LENGTH = 7;
|
||||
@ -59,6 +60,7 @@ const AuthPhoneNumber: FC<StateProps> = ({
|
||||
authNearestCountry,
|
||||
phoneCodeList,
|
||||
language,
|
||||
isTestServer,
|
||||
}) => {
|
||||
const {
|
||||
setAuthPhoneNumber,
|
||||
@ -87,11 +89,12 @@ const AuthPhoneNumber: FC<StateProps> = ({
|
||||
const hasActiveAccount = Object.values(accountsInfo).length > 0;
|
||||
const phoneNumberSlots = useMemo(() => (
|
||||
Object.entries(accountsInfo)
|
||||
.filter(([, info]) => info.isTest === isTestServer)
|
||||
.reduce((acc, [key, { phone }]) => {
|
||||
if (phone) acc[phone] = Number(key);
|
||||
return acc;
|
||||
}, {} as Record<string, number>)
|
||||
), [accountsInfo]);
|
||||
), [accountsInfo, isTestServer]);
|
||||
|
||||
const fullNumber = country ? `+${country.countryCode} ${phoneNumber || ''}` : phoneNumber;
|
||||
const canSubmit = fullNumber && fullNumber.replace(/[^\d]+/g, '').length >= MIN_NUMBER_LENGTH;
|
||||
@ -295,6 +298,7 @@ export default memo(withGlobal(
|
||||
const {
|
||||
sharedState: { settings: { language } },
|
||||
countryList: { phoneCodes: phoneCodeList },
|
||||
config,
|
||||
} = global;
|
||||
|
||||
return {
|
||||
@ -310,6 +314,7 @@ export default memo(withGlobal(
|
||||
]),
|
||||
language,
|
||||
phoneCodeList,
|
||||
isTestServer: config?.isTestServer,
|
||||
};
|
||||
},
|
||||
)(AuthPhoneNumber));
|
||||
|
||||
@ -94,6 +94,7 @@ const AccountMenuItems = ({
|
||||
onClick={account.userId === currentUser.id ? onSelectCurrent : undefined}
|
||||
href={account.userId !== currentUser.id ? getAccountSlotUrl(Number(slot)) : undefined}
|
||||
>
|
||||
{account.isTest && <span className="account-menu-item-test">T</span>}
|
||||
<FullNameTitle peer={mockUser} withEmojiStatus emojiStatusSize={REM} />
|
||||
</MenuItem>
|
||||
{hasSeparator && <MenuSeparator />}
|
||||
|
||||
@ -159,6 +159,16 @@
|
||||
.account-menu-item {
|
||||
--custom-emoji-size: 1rem;
|
||||
|
||||
&-test {
|
||||
position: absolute;
|
||||
left: 2.875rem;
|
||||
bottom: 0.0625rem;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 0.5rem;
|
||||
font-weight: var(--font-weight-medium);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.account-avatar {
|
||||
margin-inline: 0.375rem 1.125rem;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ const GiftWithdrawModal = ({ modal, hasPassword, passwordHint }: OwnProps & Stat
|
||||
{!hasPassword && (
|
||||
<>
|
||||
<span className={styles.noPassword}>{lang('ErrorPasswordMissing')}</span>
|
||||
<Button size="smaller" onClick={handleSetUpPassword}>{lang('SetUp2FA')}</Button>
|
||||
<Button className="mt-2" size="smaller" onClick={handleSetUpPassword}>{lang('SetUp2FA')}</Button>
|
||||
</>
|
||||
)}
|
||||
{hasPassword && !exportDelay && (
|
||||
|
||||
@ -52,8 +52,12 @@ addActionHandler('initApi', (global, actions): ActionReturnType => {
|
||||
|
||||
const hasTestParam = window.location.search.includes('test') || initialLocationHash?.tgWebAuthTest === '1';
|
||||
|
||||
const isTestServer = global.config?.isTestServer;
|
||||
const accountsInfo = getAccountsInfo();
|
||||
const accountIds = Object.values(accountsInfo).map(({ userId }) => userId)?.filter(Boolean);
|
||||
const accountIds = Object.values(accountsInfo)
|
||||
.filter((info) => info.isTest === isTestServer)
|
||||
.map(({ userId }) => userId)
|
||||
.filter(Boolean);
|
||||
|
||||
void initApi(actions.apiUpdate, {
|
||||
userAgent: navigator.userAgent,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user