Settings: Move sensitive content toggle to Privacy section (#1202)
This commit is contained in:
parent
d2ca29e961
commit
6b8bfdf3ab
@ -35,16 +35,14 @@ type StateProps = Pick<ISettings, (
|
|||||||
'shouldAutoPlayGifs' |
|
'shouldAutoPlayGifs' |
|
||||||
'shouldAutoPlayVideos' |
|
'shouldAutoPlayVideos' |
|
||||||
'shouldSuggestStickers' |
|
'shouldSuggestStickers' |
|
||||||
'shouldLoopStickers' |
|
'shouldLoopStickers'
|
||||||
'isSensitiveEnabled' |
|
|
||||||
'canChangeSensitive'
|
|
||||||
)> & {
|
)> & {
|
||||||
stickerSetIds?: string[];
|
stickerSetIds?: string[];
|
||||||
stickerSetsById?: Record<string, ApiStickerSet>;
|
stickerSetsById?: Record<string, ApiStickerSet>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, (
|
type DispatchProps = Pick<GlobalActions, (
|
||||||
'setSettingOption' | 'loadStickerSets' | 'loadAddedStickers' | 'loadContentSettings' | 'updateContentSettings'
|
'setSettingOption' | 'loadStickerSets' | 'loadAddedStickers'
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
const ANIMATION_LEVEL_OPTIONS = [
|
const ANIMATION_LEVEL_OPTIONS = [
|
||||||
@ -68,13 +66,9 @@ const SettingsGeneral: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
shouldAutoPlayVideos,
|
shouldAutoPlayVideos,
|
||||||
shouldSuggestStickers,
|
shouldSuggestStickers,
|
||||||
shouldLoopStickers,
|
shouldLoopStickers,
|
||||||
isSensitiveEnabled,
|
|
||||||
canChangeSensitive,
|
|
||||||
setSettingOption,
|
setSettingOption,
|
||||||
loadStickerSets,
|
loadStickerSets,
|
||||||
loadAddedStickers,
|
loadAddedStickers,
|
||||||
loadContentSettings,
|
|
||||||
updateContentSettings,
|
|
||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const stickerSettingsRef = useRef<HTMLDivElement>(null);
|
const stickerSettingsRef = useRef<HTMLDivElement>(null);
|
||||||
@ -95,8 +89,7 @@ const SettingsGeneral: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadStickerSets();
|
loadStickerSets();
|
||||||
loadContentSettings();
|
}, [loadStickerSets]);
|
||||||
}, [loadContentSettings, loadStickerSets]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (stickerSetIds && stickerSetIds.length) {
|
if (stickerSetIds && stickerSetIds.length) {
|
||||||
@ -176,19 +169,6 @@ const SettingsGeneral: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="settings-item">
|
|
||||||
<h4 className="settings-item-header" dir={lang.isRtl ? 'rtl' : undefined}>
|
|
||||||
{lang('lng_settings_sensitive_title')}
|
|
||||||
</h4>
|
|
||||||
<Checkbox
|
|
||||||
label={lang('lng_settings_sensitive_disable_filtering')}
|
|
||||||
subLabel={lang('lng_settings_sensitive_about')}
|
|
||||||
checked={Boolean(isSensitiveEnabled)}
|
|
||||||
disabled={!canChangeSensitive}
|
|
||||||
onCheck={updateContentSettings}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="settings-item">
|
<div className="settings-item">
|
||||||
<h4 className="settings-item-header" dir={lang.isRtl ? 'rtl' : undefined}>{lang('AutoDownloadMedia')}</h4>
|
<h4 className="settings-item-header" dir={lang.isRtl ? 'rtl' : undefined}>{lang('AutoDownloadMedia')}</h4>
|
||||||
|
|
||||||
@ -288,6 +268,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||||
'setSettingOption', 'loadStickerSets', 'loadAddedStickers', 'loadContentSettings', 'updateContentSettings',
|
'setSettingOption', 'loadStickerSets', 'loadAddedStickers',
|
||||||
]),
|
]),
|
||||||
)(SettingsGeneral));
|
)(SettingsGeneral));
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { pick } from '../../../util/iteratees';
|
|||||||
import useLang from '../../../hooks/useLang';
|
import useLang from '../../../hooks/useLang';
|
||||||
|
|
||||||
import ListItem from '../../ui/ListItem';
|
import ListItem from '../../ui/ListItem';
|
||||||
|
import Checkbox from '../../ui/Checkbox';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
onScreenSelect: (screen: SettingsScreens) => void;
|
onScreenSelect: (screen: SettingsScreens) => void;
|
||||||
@ -17,6 +18,8 @@ type StateProps = {
|
|||||||
hasPassword?: boolean;
|
hasPassword?: boolean;
|
||||||
blockedCount: number;
|
blockedCount: number;
|
||||||
sessionsCount: number;
|
sessionsCount: number;
|
||||||
|
isSensitiveEnabled?: boolean;
|
||||||
|
canChangeSensitive?: boolean;
|
||||||
visibilityPrivacyPhoneNumber?: PrivacyVisibility;
|
visibilityPrivacyPhoneNumber?: PrivacyVisibility;
|
||||||
visibilityPrivacyLastSeen?: PrivacyVisibility;
|
visibilityPrivacyLastSeen?: PrivacyVisibility;
|
||||||
visibilityPrivacyProfilePhoto?: PrivacyVisibility;
|
visibilityPrivacyProfilePhoto?: PrivacyVisibility;
|
||||||
@ -24,13 +27,17 @@ type StateProps = {
|
|||||||
visibilityPrivacyGroupChats?: PrivacyVisibility;
|
visibilityPrivacyGroupChats?: PrivacyVisibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, 'loadBlockedContacts' | 'loadAuthorizations' | 'loadPrivacySettings'>;
|
type DispatchProps = Pick<GlobalActions, (
|
||||||
|
'loadBlockedContacts' | 'loadAuthorizations' | 'loadPrivacySettings' | 'loadContentSettings' | 'updateContentSettings'
|
||||||
|
)>;
|
||||||
|
|
||||||
const SettingsPrivacy: FC<OwnProps & StateProps & DispatchProps> = ({
|
const SettingsPrivacy: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||||
onScreenSelect,
|
onScreenSelect,
|
||||||
hasPassword,
|
hasPassword,
|
||||||
blockedCount,
|
blockedCount,
|
||||||
sessionsCount,
|
sessionsCount,
|
||||||
|
isSensitiveEnabled,
|
||||||
|
canChangeSensitive,
|
||||||
visibilityPrivacyPhoneNumber,
|
visibilityPrivacyPhoneNumber,
|
||||||
visibilityPrivacyLastSeen,
|
visibilityPrivacyLastSeen,
|
||||||
visibilityPrivacyProfilePhoto,
|
visibilityPrivacyProfilePhoto,
|
||||||
@ -39,12 +46,15 @@ const SettingsPrivacy: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
loadPrivacySettings,
|
loadPrivacySettings,
|
||||||
loadBlockedContacts,
|
loadBlockedContacts,
|
||||||
loadAuthorizations,
|
loadAuthorizations,
|
||||||
|
loadContentSettings,
|
||||||
|
updateContentSettings,
|
||||||
}) => {
|
}) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadBlockedContacts();
|
loadBlockedContacts();
|
||||||
loadAuthorizations();
|
loadAuthorizations();
|
||||||
loadPrivacySettings();
|
loadPrivacySettings();
|
||||||
}, [loadBlockedContacts, loadAuthorizations, loadPrivacySettings]);
|
loadContentSettings();
|
||||||
|
}, [loadBlockedContacts, loadAuthorizations, loadPrivacySettings, loadContentSettings]);
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
@ -169,6 +179,19 @@ const SettingsPrivacy: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="settings-item">
|
||||||
|
<h4 className="settings-item-header" dir={lang.isRtl ? 'rtl' : undefined}>
|
||||||
|
{lang('lng_settings_sensitive_title')}
|
||||||
|
</h4>
|
||||||
|
<Checkbox
|
||||||
|
label={lang('lng_settings_sensitive_disable_filtering')}
|
||||||
|
subLabel={lang('lng_settings_sensitive_about')}
|
||||||
|
checked={Boolean(isSensitiveEnabled)}
|
||||||
|
disabled={!canChangeSensitive}
|
||||||
|
onCheck={updateContentSettings}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -177,7 +200,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
(global): StateProps => {
|
(global): StateProps => {
|
||||||
const {
|
const {
|
||||||
settings: {
|
settings: {
|
||||||
byKey: { hasPassword },
|
byKey: { hasPassword, isSensitiveEnabled, canChangeSensitive },
|
||||||
privacy,
|
privacy,
|
||||||
},
|
},
|
||||||
blocked,
|
blocked,
|
||||||
@ -188,6 +211,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
hasPassword,
|
hasPassword,
|
||||||
blockedCount: blocked.totalCount,
|
blockedCount: blocked.totalCount,
|
||||||
sessionsCount: activeSessions.length,
|
sessionsCount: activeSessions.length,
|
||||||
|
isSensitiveEnabled,
|
||||||
|
canChangeSensitive,
|
||||||
visibilityPrivacyPhoneNumber: privacy.phoneNumber && privacy.phoneNumber.visibility,
|
visibilityPrivacyPhoneNumber: privacy.phoneNumber && privacy.phoneNumber.visibility,
|
||||||
visibilityPrivacyLastSeen: privacy.lastSeen && privacy.lastSeen.visibility,
|
visibilityPrivacyLastSeen: privacy.lastSeen && privacy.lastSeen.visibility,
|
||||||
visibilityPrivacyProfilePhoto: privacy.profilePhoto && privacy.profilePhoto.visibility,
|
visibilityPrivacyProfilePhoto: privacy.profilePhoto && privacy.profilePhoto.visibility,
|
||||||
@ -196,6 +221,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||||
'loadBlockedContacts', 'loadAuthorizations', 'loadPrivacySettings',
|
'loadBlockedContacts', 'loadAuthorizations', 'loadPrivacySettings', 'loadContentSettings', 'updateContentSettings',
|
||||||
]),
|
]),
|
||||||
)(SettingsPrivacy));
|
)(SettingsPrivacy));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user