diff --git a/ts/components/session/LeftPaneSettingSection.tsx b/ts/components/session/LeftPaneSettingSection.tsx index 224a11239..2d9ae2063 100644 --- a/ts/components/session/LeftPaneSettingSection.tsx +++ b/ts/components/session/LeftPaneSettingSection.tsx @@ -108,13 +108,6 @@ const onDeleteAccount = ( setModal: any) => { const title = window.i18n('clearAllData'); const message = window.i18n('deleteAccountWarning'); - // window.confirmationDialog({ - // title, - // message, - // resolve: deleteAccount, - // okTheme: 'danger', - // }); - const clearModal = () => { setModal(null); } diff --git a/ts/components/session/SessionPasswordModal.tsx b/ts/components/session/SessionPasswordModal.tsx index 24c2dd72a..8c3d1b1a6 100644 --- a/ts/components/session/SessionPasswordModal.tsx +++ b/ts/components/session/SessionPasswordModal.tsx @@ -7,6 +7,7 @@ import { ToastUtils } from '../../session/utils'; import { SessionIconType } from './icon'; import { DefaultTheme, withTheme } from 'styled-components'; import { getPasswordHash } from '../../data/data'; +import { SessionWrapperModal } from './SessionWrapperModal'; export enum PasswordAction { Set = 'set', Change = 'change', @@ -72,7 +73,7 @@ class SessionPasswordModalInner extends React.Component { action === PasswordAction.Remove ? SessionButtonColor.Danger : SessionButtonColor.Primary; return ( - { - + ); } diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index 691780177..cc6e8e173 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -11,6 +11,8 @@ import { ConversationController } from '../../../session/conversations'; import { getConversationLookup, getConversations } from '../../../state/selectors/conversations'; import { connect } from 'react-redux'; import { getPasswordHash } from '../../../../ts/data/data'; +import { PasswordAction, SessionPasswordModal } from '../SessionPasswordModal'; +import { ModalStatusLight } from '../../OnionStatusDialog'; export enum SessionSettingCategory { Appearance = 'appearance', @@ -40,6 +42,7 @@ interface State { pwdLockError: string | null; mediaSetting: boolean | null; shouldLockSettings: boolean | null; + modal: JSX.Element | null; } interface LocalSettingType { @@ -68,6 +71,7 @@ class SettingsViewInner extends React.Component { pwdLockError: null, mediaSetting: null, shouldLockSettings: true, + modal: null }; this.settingsViewRef = React.createRef(); @@ -221,6 +225,9 @@ class SettingsViewInner extends React.Component { categoryTitle={window.i18n(`${category}SettingsTitle`)} /> + + {this.state.modal ? this.state.modal : null} +
{shouldRenderPasswordLock ? ( this.renderPasswordLock() @@ -479,10 +486,7 @@ class SettingsViewInner extends React.Component { buttonColor: SessionButtonColor.Primary, }, onClick: () => { - window.Whisper.events.trigger('showPasswordDialog', { - action: 'set', - onSuccess: this.onPasswordUpdated, - }); + this.displayPasswordModal(PasswordAction.Set); }, confirmationDialogParams: undefined, }, @@ -500,10 +504,7 @@ class SettingsViewInner extends React.Component { buttonColor: SessionButtonColor.Primary, }, onClick: () => { - window.Whisper.events.trigger('showPasswordDialog', { - action: 'change', - onSuccess: this.onPasswordUpdated, - }); + this.displayPasswordModal(PasswordAction.Change); }, confirmationDialogParams: undefined, }, @@ -521,16 +522,27 @@ class SettingsViewInner extends React.Component { buttonColor: SessionButtonColor.Danger, }, onClick: () => { - window.Whisper.events.trigger('showPasswordDialog', { - action: 'remove', - onSuccess: this.onPasswordUpdated, - }); + this.displayPasswordModal(PasswordAction.Remove); }, confirmationDialogParams: undefined, }, ]; } + private displayPasswordModal(passwordAction: PasswordAction) { + this.setState({ + ...this.state, + modal: this.clearModal()} onOk={this.onPasswordUpdated} action={passwordAction}> + }) + } + + private clearModal(): void { + this.setState({ + ...this.state, + modal: null + }); + } + private getBlockedUserSettings(): Array { const results: Array = []; const blockedNumbers = BlockedNumberController.getBlockedNumbers();