feat: added new hide recovery password setting

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

@ -102,6 +102,7 @@ function setupLeftPane(forceUpdateInboxComponent: () => void) {
settingsLinkPreview: Storage.getBoolOrFalse(SettingsKey.settingsLinkPreview),
hasFollowSystemThemeEnabled: Storage.getBoolOrFalse(SettingsKey.hasFollowSystemThemeEnabled),
hasShiftSendEnabled: Storage.getBoolOrFalse(SettingsKey.hasShiftSendEnabled),
hideRecoveryPassword: Storage.getBoolOrFalse(SettingsKey.hideRecoveryPassword),
})
);
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 { useDispatch } from 'react-redux';
import styled from 'styled-components';
import { updateTermsOfServicePrivacyModal } from '../../state/onboarding/ducks/modals';
import { SessionWrapperModal } from '../SessionWrapperModal';
import { Flex } from '../basic/Flex';
import { SessionButton, SessionButtonType } from '../basic/SessionButton';
import { SpacerSM } from '../basic/Text';
// 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);
`;
import { ModalConfirmButtonContainer } from '../buttons/ModalConfirmButtonContainer';
export type TermsOfServicePrivacyDialogProps = {
show: boolean;
@ -37,28 +31,26 @@ export function TermsOfServicePrivacyDialog(props: TermsOfServicePrivacyDialogPr
showHeader={true}
headerReverse={true}
>
<div className="session-modal__centered">
<span>{window.i18n('urlOpenBrowser')}</span>
<SpacerSM />
<ConfirmButtonContainer container={true} justifyContent="center" alignItems="center">
<SessionButton
text={window.i18n('termsOfService')}
buttonType={SessionButtonType.Ghost}
onClick={() => {
void shell.openExternal('https://getsession.org/terms-of-service');
}}
dataTestId="terms-of-service-button"
/>
<SessionButton
text={window.i18n('privacyPolicy')}
buttonType={SessionButtonType.Ghost}
onClick={() => {
void shell.openExternal('https://getsession.org/privacy-policy');
}}
dataTestId="privacy-policy-button"
/>
</ConfirmButtonContainer>
</div>
<span>{window.i18n('urlOpenBrowser')}</span>
<SpacerSM />
<ModalConfirmButtonContainer container={true} justifyContent="center" alignItems="center">
<SessionButton
text={window.i18n('termsOfService')}
buttonType={SessionButtonType.Ghost}
onClick={() => {
void shell.openExternal('https://getsession.org/terms-of-service');
}}
dataTestId="terms-of-service-button"
/>
<SessionButton
text={window.i18n('privacyPolicy')}
buttonType={SessionButtonType.Ghost}
onClick={() => {
void shell.openExternal('https://getsession.org/privacy-policy');
}}
dataTestId="privacy-policy-button"
/>
</ModalConfirmButtonContainer>
</SessionWrapperModal>
);
}

@ -15,6 +15,7 @@ const hasSyncedInitialConfigurationItem = 'hasSyncedInitialConfigurationItem';
const lastAvatarUploadTimestamp = 'lastAvatarUploadTimestamp';
const hasLinkPreviewPopupBeenDisplayed = 'hasLinkPreviewPopupBeenDisplayed';
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)
const latestUserProfileEnvelopeTimestamp = 'latestUserProfileEnvelopeTimestamp';
@ -42,6 +43,7 @@ export const SettingsKey = {
latestUserGroupEnvelopeTimestamp,
latestUserContactsEnvelopeTimestamp,
hasFollowSystemThemeEnabled,
hideRecoveryPassword,
} as const;
export const KNOWN_BLINDED_KEYS_ITEM = 'KNOWN_BLINDED_KEYS_ITEM';

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

@ -17,6 +17,9 @@ const getHasFollowSystemThemeEnabled = (state: StateType) =>
const getHasShiftSendEnabled = (state: StateType) =>
state.settings.settingsBools[SettingsKey.hasShiftSendEnabled];
const getHideRecoveryPassword = (state: StateType) =>
state.settings.settingsBools[SettingsKey.hideRecoveryPassword];
export const useHasLinkPreviewEnabled = () => {
const value = useSelector(getLinkPreviewEnabled);
return Boolean(value);
@ -42,3 +45,9 @@ export const useHasEnterSendEnabled = () => {
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('device_name'),
Storage.remove('userAgent'),
Storage.remove(SettingsKey.settingsReadReceipt),
Storage.remove(SettingsKey.settingsTypingIndicator),
Storage.remove('regionCode'),
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
@ -181,6 +182,9 @@ async function createAccount(identityKeyPair: SessionKeyPair) {
await Storage.put(SettingsKey.settingsOpengroupPruning, true);
await window.setOpengroupPruning(true);
// turn off hide recovery password by default
await Storage.put(SettingsKey.hideRecoveryPassword, false);
await setLocalPubKey(pubKeyString);
}

Loading…
Cancel
Save