Experimental: Add "Don't hide login code in chat list" toggle (#3147)
This commit is contained in:
parent
829080a98f
commit
dda81b5962
@ -2,7 +2,7 @@ import React, { memo } from '../../../lib/teact/teact';
|
|||||||
|
|
||||||
import type { FC } from '../../../lib/teact/teact';
|
import type { FC } from '../../../lib/teact/teact';
|
||||||
|
|
||||||
import { getActions } from '../../../global';
|
import { getActions, withGlobal } from '../../../global';
|
||||||
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
import { LOCAL_TGS_URLS } from '../../common/helpers/animatedAssets';
|
||||||
|
|
||||||
import useHistoryBack from '../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../hooks/useHistoryBack';
|
||||||
@ -10,17 +10,23 @@ import useLang from '../../../hooks/useLang';
|
|||||||
|
|
||||||
import AnimatedIcon from '../../common/AnimatedIcon';
|
import AnimatedIcon from '../../common/AnimatedIcon';
|
||||||
import ListItem from '../../ui/ListItem';
|
import ListItem from '../../ui/ListItem';
|
||||||
|
import Checkbox from '../../ui/Checkbox';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
isActive?: boolean;
|
isActive?: boolean;
|
||||||
onReset: () => void;
|
onReset: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SettingsExperimental: FC<OwnProps> = ({
|
type StateProps = {
|
||||||
|
shouldShowLoginCodeInChatList?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SettingsExperimental: FC<OwnProps & StateProps> = ({
|
||||||
isActive,
|
isActive,
|
||||||
onReset,
|
onReset,
|
||||||
|
shouldShowLoginCodeInChatList,
|
||||||
}) => {
|
}) => {
|
||||||
const { requestConfetti } = getActions();
|
const { requestConfetti, setSettingOption } = getActions();
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
useHistoryBack({
|
useHistoryBack({
|
||||||
@ -38,7 +44,7 @@ const SettingsExperimental: FC<OwnProps> = ({
|
|||||||
nonInteractive
|
nonInteractive
|
||||||
noLoop={false}
|
noLoop={false}
|
||||||
/>
|
/>
|
||||||
<p className="settings-item-description" dir="auto">{lang('lng_settings_experimental_about')}</p>
|
<p className="settings-item-description pt-3" dir="auto">{lang('lng_settings_experimental_about')}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="settings-item">
|
<div className="settings-item">
|
||||||
<ListItem
|
<ListItem
|
||||||
@ -48,9 +54,22 @@ const SettingsExperimental: FC<OwnProps> = ({
|
|||||||
>
|
>
|
||||||
<div className="title">Launch some confetti!</div>
|
<div className="title">Launch some confetti!</div>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
|
<Checkbox
|
||||||
|
label="Show login code in chat list"
|
||||||
|
checked={Boolean(shouldShowLoginCodeInChatList)}
|
||||||
|
// eslint-disable-next-line react/jsx-no-bind
|
||||||
|
onCheck={() => setSettingOption({ shouldShowLoginCodeInChatList: !shouldShowLoginCodeInChatList })}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(SettingsExperimental);
|
export default memo(withGlobal(
|
||||||
|
(global): StateProps => {
|
||||||
|
return {
|
||||||
|
shouldShowLoginCodeInChatList: global.settings.byKey.shouldShowLoginCodeInChatList,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
)(SettingsExperimental));
|
||||||
|
|||||||
@ -303,7 +303,9 @@ export function extractMessageText(message: ApiMessage, inChatList = false) {
|
|||||||
const { text } = contentText;
|
const { text } = contentText;
|
||||||
let { entities } = contentText;
|
let { entities } = contentText;
|
||||||
|
|
||||||
if (text && inChatList && message.chatId === SERVICE_NOTIFICATIONS_USER_ID) {
|
if (text && inChatList && message.chatId === SERVICE_NOTIFICATIONS_USER_ID
|
||||||
|
// eslint-disable-next-line eslint-multitab-tt/no-immediate-global
|
||||||
|
&& !getGlobal().settings.byKey.shouldShowLoginCodeInChatList) {
|
||||||
const authCode = text.match(/^\D*([\d-]{5,7})\D/)?.[1];
|
const authCode = text.match(/^\D*([\d-]{5,7})\D/)?.[1];
|
||||||
if (authCode) {
|
if (authCode) {
|
||||||
entities = [
|
entities = [
|
||||||
|
|||||||
@ -99,6 +99,7 @@ export interface ISettings extends NotifySettings, Record<string, any> {
|
|||||||
canTranslateChats: boolean;
|
canTranslateChats: boolean;
|
||||||
doNotTranslate: string[];
|
doNotTranslate: string[];
|
||||||
canDisplayChatInTitle: boolean;
|
canDisplayChatInTitle: boolean;
|
||||||
|
shouldShowLoginCodeInChatList?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiPrivacySettings {
|
export interface ApiPrivacySettings {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user