feat: added new hide recovery password setting

pull/3083/head
William Grant 12 months ago
parent 7cd7dea2b6
commit 51534d4cc9

@ -102,6 +102,7 @@ function setupLeftPane(forceUpdateInboxComponent: () => void) {
settingsLinkPreview: Storage.getBoolOrFalse(SettingsKey.settingsLinkPreview), settingsLinkPreview: Storage.getBoolOrFalse(SettingsKey.settingsLinkPreview),
hasFollowSystemThemeEnabled: Storage.getBoolOrFalse(SettingsKey.hasFollowSystemThemeEnabled), hasFollowSystemThemeEnabled: Storage.getBoolOrFalse(SettingsKey.hasFollowSystemThemeEnabled),
hasShiftSendEnabled: Storage.getBoolOrFalse(SettingsKey.hasShiftSendEnabled), hasShiftSendEnabled: Storage.getBoolOrFalse(SettingsKey.hasShiftSendEnabled),
hideRecoveryPassword: Storage.getBoolOrFalse(SettingsKey.hideRecoveryPassword),
}) })
); );
forceUpdateInboxComponent(); forceUpdateInboxComponent();

@ -0,0 +1,12 @@
import styled from 'styled-components';
import { Flex } from '../basic/Flex';
/** We use this in the modals only to bypass the padding on the body so the buttons take up the full space width of the modal window
* See .session-modal__body for padding values
*/
export const ModalConfirmButtonContainer = styled(Flex)`
margin-top: 0px;
margin-right: calc(var(--margins-lg) * -1);
margin-bottom: calc(var(--margins-lg) * -1);
margin-left: calc(var(--margins-lg) * -1);
`;

@ -1,16 +1,10 @@
import { shell } from 'electron'; import { shell } from 'electron';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import styled from 'styled-components';
import { updateTermsOfServicePrivacyModal } from '../../state/onboarding/ducks/modals'; import { updateTermsOfServicePrivacyModal } from '../../state/onboarding/ducks/modals';
import { SessionWrapperModal } from '../SessionWrapperModal'; import { SessionWrapperModal } from '../SessionWrapperModal';
import { Flex } from '../basic/Flex';
import { SessionButton, SessionButtonType } from '../basic/SessionButton'; import { SessionButton, SessionButtonType } from '../basic/SessionButton';
import { SpacerSM } from '../basic/Text'; import { SpacerSM } from '../basic/Text';
import { ModalConfirmButtonContainer } from '../buttons/ModalConfirmButtonContainer';
// NOTE we want to bypass the padding on the modal body so the buttons take up the full space
const ConfirmButtonContainer = styled(Flex)`
margin: 0px calc(var(--margins-lg) * -1) calc(var(--margins-lg) * -1) calc(var(--margins-lg) * -1);
`;
export type TermsOfServicePrivacyDialogProps = { export type TermsOfServicePrivacyDialogProps = {
show: boolean; show: boolean;
@ -37,28 +31,26 @@ export function TermsOfServicePrivacyDialog(props: TermsOfServicePrivacyDialogPr
showHeader={true} showHeader={true}
headerReverse={true} headerReverse={true}
> >
<div className="session-modal__centered"> <span>{window.i18n('urlOpenBrowser')}</span>
<span>{window.i18n('urlOpenBrowser')}</span> <SpacerSM />
<SpacerSM /> <ModalConfirmButtonContainer container={true} justifyContent="center" alignItems="center">
<ConfirmButtonContainer container={true} justifyContent="center" alignItems="center"> <SessionButton
<SessionButton text={window.i18n('termsOfService')}
text={window.i18n('termsOfService')} buttonType={SessionButtonType.Ghost}
buttonType={SessionButtonType.Ghost} onClick={() => {
onClick={() => { void shell.openExternal('https://getsession.org/terms-of-service');
void shell.openExternal('https://getsession.org/terms-of-service'); }}
}} dataTestId="terms-of-service-button"
dataTestId="terms-of-service-button" />
/> <SessionButton
<SessionButton text={window.i18n('privacyPolicy')}
text={window.i18n('privacyPolicy')} buttonType={SessionButtonType.Ghost}
buttonType={SessionButtonType.Ghost} onClick={() => {
onClick={() => { void shell.openExternal('https://getsession.org/privacy-policy');
void shell.openExternal('https://getsession.org/privacy-policy'); }}
}} dataTestId="privacy-policy-button"
dataTestId="privacy-policy-button" />
/> </ModalConfirmButtonContainer>
</ConfirmButtonContainer>
</div>
</SessionWrapperModal> </SessionWrapperModal>
); );
} }

@ -15,6 +15,7 @@ const hasSyncedInitialConfigurationItem = 'hasSyncedInitialConfigurationItem';
const lastAvatarUploadTimestamp = 'lastAvatarUploadTimestamp'; const lastAvatarUploadTimestamp = 'lastAvatarUploadTimestamp';
const hasLinkPreviewPopupBeenDisplayed = 'hasLinkPreviewPopupBeenDisplayed'; const hasLinkPreviewPopupBeenDisplayed = 'hasLinkPreviewPopupBeenDisplayed';
const hasFollowSystemThemeEnabled = 'hasFollowSystemThemeEnabled'; const hasFollowSystemThemeEnabled = 'hasFollowSystemThemeEnabled';
const hideRecoveryPassword = 'hideRecoveryPassword';
// user config tracking timestamps (to discard incoming messages which would make a change we reverted in the last config message we merged) // user config tracking timestamps (to discard incoming messages which would make a change we reverted in the last config message we merged)
const latestUserProfileEnvelopeTimestamp = 'latestUserProfileEnvelopeTimestamp'; const latestUserProfileEnvelopeTimestamp = 'latestUserProfileEnvelopeTimestamp';
@ -42,6 +43,7 @@ export const SettingsKey = {
latestUserGroupEnvelopeTimestamp, latestUserGroupEnvelopeTimestamp,
latestUserContactsEnvelopeTimestamp, latestUserContactsEnvelopeTimestamp,
hasFollowSystemThemeEnabled, hasFollowSystemThemeEnabled,
hideRecoveryPassword,
} as const; } as const;
export const KNOWN_BLINDED_KEYS_ITEM = 'KNOWN_BLINDED_KEYS_ITEM'; export const KNOWN_BLINDED_KEYS_ITEM = 'KNOWN_BLINDED_KEYS_ITEM';

@ -9,6 +9,7 @@ const SettingsBoolsKeyTrackedInRedux = [
SettingsKey.hasBlindedMsgRequestsEnabled, SettingsKey.hasBlindedMsgRequestsEnabled,
SettingsKey.hasFollowSystemThemeEnabled, SettingsKey.hasFollowSystemThemeEnabled,
SettingsKey.hasShiftSendEnabled, SettingsKey.hasShiftSendEnabled,
SettingsKey.hideRecoveryPassword,
] as const; ] as const;
export type SettingsState = { export type SettingsState = {
@ -23,6 +24,7 @@ export function getSettingsInitialState() {
hasBlindedMsgRequestsEnabled: false, hasBlindedMsgRequestsEnabled: false,
hasFollowSystemThemeEnabled: false, hasFollowSystemThemeEnabled: false,
hasShiftSendEnabled: false, hasShiftSendEnabled: false,
hideRecoveryPassword: false,
}, },
}; };
} }
@ -53,6 +55,7 @@ const settingsSlice = createSlice({
hasBlindedMsgRequestsEnabled: boolean; hasBlindedMsgRequestsEnabled: boolean;
hasFollowSystemThemeEnabled: boolean; hasFollowSystemThemeEnabled: boolean;
hasShiftSendEnabled: boolean; hasShiftSendEnabled: boolean;
hideRecoveryPassword: boolean;
}> }>
) { ) {
const { const {
@ -61,6 +64,7 @@ const settingsSlice = createSlice({
settingsLinkPreview, settingsLinkPreview,
someDeviceOutdatedSyncing, someDeviceOutdatedSyncing,
hasShiftSendEnabled, hasShiftSendEnabled,
hideRecoveryPassword,
} = payload; } = payload;
state.settingsBools.someDeviceOutdatedSyncing = someDeviceOutdatedSyncing; state.settingsBools.someDeviceOutdatedSyncing = someDeviceOutdatedSyncing;
@ -68,6 +72,7 @@ const settingsSlice = createSlice({
state.settingsBools.hasBlindedMsgRequestsEnabled = hasBlindedMsgRequestsEnabled; state.settingsBools.hasBlindedMsgRequestsEnabled = hasBlindedMsgRequestsEnabled;
state.settingsBools.hasFollowSystemThemeEnabled = hasFollowSystemThemeEnabled; state.settingsBools.hasFollowSystemThemeEnabled = hasFollowSystemThemeEnabled;
state.settingsBools.hasShiftSendEnabled = hasShiftSendEnabled; state.settingsBools.hasShiftSendEnabled = hasShiftSendEnabled;
state.settingsBools.hideRecoveryPassword = hideRecoveryPassword;
return state; return state;
}, },

@ -17,6 +17,9 @@ const getHasFollowSystemThemeEnabled = (state: StateType) =>
const getHasShiftSendEnabled = (state: StateType) => const getHasShiftSendEnabled = (state: StateType) =>
state.settings.settingsBools[SettingsKey.hasShiftSendEnabled]; state.settings.settingsBools[SettingsKey.hasShiftSendEnabled];
const getHideRecoveryPassword = (state: StateType) =>
state.settings.settingsBools[SettingsKey.hideRecoveryPassword];
export const useHasLinkPreviewEnabled = () => { export const useHasLinkPreviewEnabled = () => {
const value = useSelector(getLinkPreviewEnabled); const value = useSelector(getLinkPreviewEnabled);
return Boolean(value); return Boolean(value);
@ -42,3 +45,9 @@ export const useHasEnterSendEnabled = () => {
return Boolean(value); return Boolean(value);
}; };
export const useHideRecoveryPasswordEnabled = () => {
const value = useSelector(getHideRecoveryPassword);
return Boolean(value);
};

@ -158,10 +158,11 @@ async function createAccount(identityKeyPair: SessionKeyPair) {
Storage.remove('number_id'), Storage.remove('number_id'),
Storage.remove('device_name'), Storage.remove('device_name'),
Storage.remove('userAgent'), Storage.remove('userAgent'),
Storage.remove(SettingsKey.settingsReadReceipt),
Storage.remove(SettingsKey.settingsTypingIndicator),
Storage.remove('regionCode'), Storage.remove('regionCode'),
Storage.remove('local_attachment_encrypted_key'), Storage.remove('local_attachment_encrypted_key'),
Storage.remove(SettingsKey.settingsReadReceipt),
Storage.remove(SettingsKey.settingsTypingIndicator),
Storage.remove(SettingsKey.hideRecoveryPassword),
]); ]);
// update our own identity key, which may have changed // update our own identity key, which may have changed
@ -181,6 +182,9 @@ async function createAccount(identityKeyPair: SessionKeyPair) {
await Storage.put(SettingsKey.settingsOpengroupPruning, true); await Storage.put(SettingsKey.settingsOpengroupPruning, true);
await window.setOpengroupPruning(true); await window.setOpengroupPruning(true);
// turn off hide recovery password by default
await Storage.put(SettingsKey.hideRecoveryPassword, false);
await setLocalPubKey(pubKeyString); await setLocalPubKey(pubKeyString);
} }

Loading…
Cancel
Save