fix: removed SeedModal code

pull/3083/head
William Grant 2 years ago
parent fb3a87a5f5
commit 51a0fa3b1e

@ -430,7 +430,6 @@
"recoveryPasswordHidePermanentlyDescription2": "Are you sure you want to permanently hide your recovery password on this device? This cannot be undone.",
"recoveryPasswordHideRecoveryPasswordDescription": "Permanently hide your recover password on this device.",
"recoveryPasswordWarningSendDescription": "This is your recovery password. If you send it to someone they'll have full access to your account.",
"recoveryPhraseSavePromptMain": "Your recovery password is the master key to your Account ID — you can use it to restore your Account ID if you lose access to your device. Store your recovery password in a safe place, and don't give it to anyone.",
"remove": "Remove",
"removeAccountPasswordDescription": "Remove the password required to unlock Session.",
"removeAccountPasswordTitle": "Remove Password",

@ -13,7 +13,6 @@ import {
getOnionPathDialog,
getReactClearAllDialog,
getReactListDialog,
getRecoveryPhraseDialog,
getRemoveModeratorsModal,
getSessionPasswordDialog,
getUpdateGroupMembersModal,
@ -34,7 +33,6 @@ import { ReactClearAllModal } from './ReactClearAllModal';
import { ReactListModal } from './ReactListModal';
import { SessionConfirm } from './SessionConfirm';
import { SessionNicknameDialog } from './SessionNicknameDialog';
import { SessionSeedModal } from './SessionSeedModal';
import { SessionSetPasswordDialog } from './SessionSetPasswordDialog';
import { UpdateGroupMembersDialog } from './UpdateGroupMembersDialog';
import { UpdateGroupNameDialog } from './UpdateGroupNameDialog';
@ -51,7 +49,6 @@ export const ModalContainer = () => {
const changeNicknameModal = useSelector(getChangeNickNameDialog);
const editProfileModalState = useSelector(getEditProfileDialog);
const onionPathModalState = useSelector(getOnionPathDialog);
const recoveryPhraseModalState = useSelector(getRecoveryPhraseDialog);
const enterPasswordModalState = useSelector(getEnterPasswordModalState);
const sessionPasswordModalState = useSelector(getSessionPasswordDialog);
const deleteAccountModalState = useSelector(getDeleteAccountModalState);
@ -75,7 +72,6 @@ export const ModalContainer = () => {
{changeNicknameModal && <SessionNicknameDialog {...changeNicknameModal} />}
{editProfileModalState && <EditProfileDialog {...editProfileModalState} />}
{onionPathModalState && <OnionPathModal {...onionPathModalState} />}
{recoveryPhraseModalState && <SessionSeedModal {...recoveryPhraseModalState} />}
{enterPasswordModalState && <EnterPasswordModal {...enterPasswordModalState} />}
{sessionPasswordModalState && <SessionSetPasswordDialog {...sessionPasswordModalState} />}
{deleteAccountModalState && <DeleteAccountModal {...deleteAccountModalState} />}

@ -1,142 +0,0 @@
import { useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';
import { ToastUtils } from '../../session/utils';
import { mnDecode } from '../../session/crypto/mnemonic';
import { recoveryPhraseModal } from '../../state/ducks/modalDialog';
import { SpacerSM } from '../basic/Text';
import { usePasswordModal } from '../../hooks/usePasswordModal';
import { getTheme } from '../../state/selectors/theme';
import { getThemeValue } from '../../themes/globals';
import { getCurrentRecoveryPhrase } from '../../util/storage';
import { SessionQRCode } from '../SessionQRCode';
import { SessionWrapperModal } from '../SessionWrapperModal';
import { SessionButton, SessionButtonType } from '../basic/SessionButton';
interface SeedProps {
recoveryPhrase: string;
onClickCopy?: () => any;
}
const StyledRecoveryPhrase = styled.i``;
const Seed = (props: SeedProps) => {
const { recoveryPhrase, onClickCopy } = props;
const dispatch = useDispatch();
const theme = useSelector(getTheme);
const hexEncodedSeed = mnDecode(recoveryPhrase, 'english');
const copyRecoveryPhrase = (recoveryPhraseToCopy: string) => {
window.clipboard.writeText(recoveryPhraseToCopy);
ToastUtils.pushCopiedToClipBoard();
if (onClickCopy) {
onClickCopy();
}
dispatch(recoveryPhraseModal(null));
};
return (
<>
<div className="session-modal__centered text-center">
<p
className="session-modal__description"
style={{
lineHeight: '1.3333',
marginTop: '0px',
marginBottom: 'var(--margins-md)',
maxWidth: '600px',
}}
>
{window.i18n('recoveryPhraseSavePromptMain')}
</p>
<SessionQRCode
id={'session-recovery-passwod'}
value={hexEncodedSeed}
size={240}
backgroundColor={getThemeValue(
theme.includes('dark') ? '--text-primary-color' : '--background-primary-color'
)}
foregroundColor={getThemeValue(
theme.includes('dark') ? '--background-primary-color' : '--text-primary-color'
)}
logoImage={'./images/session/qr/shield.svg'}
logoWidth={56}
logoHeight={56}
logoIsSVG={true}
theme={theme}
style={{ margin: '0 auto var(--margins-lg)' }}
/>
<StyledRecoveryPhrase
data-testid="recovery-phrase-seed-modal"
className="session-modal__text-highlight"
>
{recoveryPhrase}
</StyledRecoveryPhrase>
</div>
<div
className="session-modal__button-group"
style={{ justifyContent: 'center', width: '100%' }}
>
<SessionButton
text={window.i18n('editMenuCopy')}
buttonType={SessionButtonType.Simple}
onClick={() => {
copyRecoveryPhrase(recoveryPhrase);
}}
/>
</div>
</>
);
};
const StyledSeedModalContainer = styled.div`
margin: var(--margins-md) var(--margins-sm);
`;
interface ModalInnerProps {
onClickOk?: () => any;
}
const SessionSeedModalInner = (props: ModalInnerProps) => {
const { onClickOk } = props;
const [loadingSeed, setLoadingSeed] = useState(true);
const [recoveryPhrase, setRecoveryPhrase] = useState('');
const dispatch = useDispatch();
const onClose = () => dispatch(recoveryPhraseModal(null));
usePasswordModal({
onSuccess: () => {
const newRecoveryPhrase = getCurrentRecoveryPhrase();
setRecoveryPhrase(newRecoveryPhrase);
setLoadingSeed(false);
},
onClose,
title: window.i18n('sessionRecoveryPassword'),
});
if (loadingSeed) {
return null;
}
return (
<SessionWrapperModal
title={window.i18n('sessionRecoveryPassword')}
onClose={onClose}
showExitIcon={true}
>
<StyledSeedModalContainer>
<SpacerSM />
<Seed recoveryPhrase={recoveryPhrase} onClickCopy={onClickOk} />
</StyledSeedModalContainer>
</SessionWrapperModal>
);
};
export const SessionSeedModal = SessionSeedModalInner;

@ -20,7 +20,6 @@ export type UpdateGroupNameModalState = InviteContactModalState;
export type ChangeNickNameModalState = InviteContactModalState;
export type EditProfileModalState = object | null;
export type OnionPathModalState = EditProfileModalState;
export type RecoveryPhraseModalState = EditProfileModalState;
export type EnterPasswordModalState = EnterPasswordModalProps | null;
export type DeleteAccountModalState = EditProfileModalState;
@ -53,7 +52,6 @@ export type ModalState = {
nickNameModal: ChangeNickNameModalState;
editProfileModal: EditProfileModalState;
onionPathModal: OnionPathModalState;
recoveryPhraseModal: RecoveryPhraseModalState;
enterPasswordModal: EnterPasswordModalState;
sessionPasswordModal: SessionPasswordModalState;
deleteAccountModal: DeleteAccountModalState;
@ -75,7 +73,6 @@ export const initialModalState: ModalState = {
nickNameModal: null,
editProfileModal: null,
onionPathModal: null,
recoveryPhraseModal: null,
enterPasswordModal: null,
sessionPasswordModal: null,
deleteAccountModal: null,
@ -122,9 +119,6 @@ const ModalSlice = createSlice({
onionPathModal(state, action: PayloadAction<OnionPathModalState | null>) {
return { ...state, onionPathModal: action.payload };
},
recoveryPhraseModal(state, action: PayloadAction<RecoveryPhraseModalState | null>) {
return { ...state, recoveryPhraseModal: action.payload };
},
updateEnterPasswordModal(state, action: PayloadAction<EnterPasswordModalState | null>) {
return { ...state, enterPasswordModal: action.payload };
},
@ -161,7 +155,6 @@ export const {
changeNickNameModal,
editProfileModal,
onionPathModal,
recoveryPhraseModal,
updateEnterPasswordModal,
sessionPassword,
updateDeleteAccountModal,

@ -14,7 +14,6 @@ import {
ModalState,
OnionPathModalState,
ReactModalsState,
RecoveryPhraseModalState,
RemoveModeratorsModalState,
SessionPasswordModalState,
UpdateGroupMembersModalState,
@ -82,11 +81,6 @@ export const getOnionPathDialog = createSelector(
(state: ModalState): OnionPathModalState => state.onionPathModal
);
export const getRecoveryPhraseDialog = createSelector(
getModal,
(state: ModalState): RecoveryPhraseModalState => state.recoveryPhraseModal
);
export const getEnterPasswordModalState = createSelector(
getModal,
(state: ModalState): EnterPasswordModalState => state.enterPasswordModal

@ -430,7 +430,6 @@ export type LocalizerKeys =
| 'recoveryPasswordHidePermanentlyDescription2'
| 'recoveryPasswordHideRecoveryPasswordDescription'
| 'recoveryPasswordWarningSendDescription'
| 'recoveryPhraseSavePromptMain'
| 'remove'
| 'removeAccountPasswordDescription'
| 'removeAccountPasswordTitle'

Loading…
Cancel
Save