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;
|
language?: string;
|
||||||
phoneCodeList: ApiCountryCode[];
|
phoneCodeList: ApiCountryCode[];
|
||||||
|
isTestServer?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MIN_NUMBER_LENGTH = 7;
|
const MIN_NUMBER_LENGTH = 7;
|
||||||
@ -59,6 +60,7 @@ const AuthPhoneNumber: FC<StateProps> = ({
|
|||||||
authNearestCountry,
|
authNearestCountry,
|
||||||
phoneCodeList,
|
phoneCodeList,
|
||||||
language,
|
language,
|
||||||
|
isTestServer,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
setAuthPhoneNumber,
|
setAuthPhoneNumber,
|
||||||
@ -87,11 +89,12 @@ const AuthPhoneNumber: FC<StateProps> = ({
|
|||||||
const hasActiveAccount = Object.values(accountsInfo).length > 0;
|
const hasActiveAccount = Object.values(accountsInfo).length > 0;
|
||||||
const phoneNumberSlots = useMemo(() => (
|
const phoneNumberSlots = useMemo(() => (
|
||||||
Object.entries(accountsInfo)
|
Object.entries(accountsInfo)
|
||||||
|
.filter(([, info]) => info.isTest === isTestServer)
|
||||||
.reduce((acc, [key, { phone }]) => {
|
.reduce((acc, [key, { phone }]) => {
|
||||||
if (phone) acc[phone] = Number(key);
|
if (phone) acc[phone] = Number(key);
|
||||||
return acc;
|
return acc;
|
||||||
}, {} as Record<string, number>)
|
}, {} as Record<string, number>)
|
||||||
), [accountsInfo]);
|
), [accountsInfo, isTestServer]);
|
||||||
|
|
||||||
const fullNumber = country ? `+${country.countryCode} ${phoneNumber || ''}` : phoneNumber;
|
const fullNumber = country ? `+${country.countryCode} ${phoneNumber || ''}` : phoneNumber;
|
||||||
const canSubmit = fullNumber && fullNumber.replace(/[^\d]+/g, '').length >= MIN_NUMBER_LENGTH;
|
const canSubmit = fullNumber && fullNumber.replace(/[^\d]+/g, '').length >= MIN_NUMBER_LENGTH;
|
||||||
@ -295,6 +298,7 @@ export default memo(withGlobal(
|
|||||||
const {
|
const {
|
||||||
sharedState: { settings: { language } },
|
sharedState: { settings: { language } },
|
||||||
countryList: { phoneCodes: phoneCodeList },
|
countryList: { phoneCodes: phoneCodeList },
|
||||||
|
config,
|
||||||
} = global;
|
} = global;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -310,6 +314,7 @@ export default memo(withGlobal(
|
|||||||
]),
|
]),
|
||||||
language,
|
language,
|
||||||
phoneCodeList,
|
phoneCodeList,
|
||||||
|
isTestServer: config?.isTestServer,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
)(AuthPhoneNumber));
|
)(AuthPhoneNumber));
|
||||||
|
|||||||
@ -94,6 +94,7 @@ const AccountMenuItems = ({
|
|||||||
onClick={account.userId === currentUser.id ? onSelectCurrent : undefined}
|
onClick={account.userId === currentUser.id ? onSelectCurrent : undefined}
|
||||||
href={account.userId !== currentUser.id ? getAccountSlotUrl(Number(slot)) : 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} />
|
<FullNameTitle peer={mockUser} withEmojiStatus emojiStatusSize={REM} />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{hasSeparator && <MenuSeparator />}
|
{hasSeparator && <MenuSeparator />}
|
||||||
|
|||||||
@ -159,6 +159,16 @@
|
|||||||
.account-menu-item {
|
.account-menu-item {
|
||||||
--custom-emoji-size: 1rem;
|
--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 {
|
.account-avatar {
|
||||||
margin-inline: 0.375rem 1.125rem;
|
margin-inline: 0.375rem 1.125rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,7 +133,7 @@ const GiftWithdrawModal = ({ modal, hasPassword, passwordHint }: OwnProps & Stat
|
|||||||
{!hasPassword && (
|
{!hasPassword && (
|
||||||
<>
|
<>
|
||||||
<span className={styles.noPassword}>{lang('ErrorPasswordMissing')}</span>
|
<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 && (
|
{hasPassword && !exportDelay && (
|
||||||
|
|||||||
@ -52,8 +52,12 @@ addActionHandler('initApi', (global, actions): ActionReturnType => {
|
|||||||
|
|
||||||
const hasTestParam = window.location.search.includes('test') || initialLocationHash?.tgWebAuthTest === '1';
|
const hasTestParam = window.location.search.includes('test') || initialLocationHash?.tgWebAuthTest === '1';
|
||||||
|
|
||||||
|
const isTestServer = global.config?.isTestServer;
|
||||||
const accountsInfo = getAccountsInfo();
|
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, {
|
void initApi(actions.apiUpdate, {
|
||||||
userAgent: navigator.userAgent,
|
userAgent: navigator.userAgent,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user