diff --git a/js/background.js b/js/background.js index 2de2d427e..6991500e5 100644 --- a/js/background.js +++ b/js/background.js @@ -982,6 +982,12 @@ } }); + Whisper.events.on('showPasswordDialog', async (options) => { + if (appView) { + appView.showPasswordDialog(options); + } + }); + Whisper.events.on('showDevicePairingDialog', async (options = {}) => { if (appView) { appView.showDevicePairingDialog(options); diff --git a/ts/components/session/settings/SessionSettings.tsx b/ts/components/session/settings/SessionSettings.tsx index f2a153d8a..259468595 100644 --- a/ts/components/session/settings/SessionSettings.tsx +++ b/ts/components/session/settings/SessionSettings.tsx @@ -524,11 +524,12 @@ export class SettingsView extends React.Component { buttonText: window.i18n('setPassword'), buttonColor: SessionButtonColor.Primary, }, - onClick: () => - window.showPasswordDialog({ + onClick: () => { + window.Whisper.events.trigger('showPasswordDialog', { action: 'set', onSuccess: this.onPasswordUpdated, - }), + }); + }, confirmationDialogParams: undefined, }, { @@ -544,11 +545,12 @@ export class SettingsView extends React.Component { buttonText: window.i18n('changePassword'), buttonColor: SessionButtonColor.Primary, }, - onClick: () => - window.showPasswordDialog({ - action: 'change', - onSuccess: this.onPasswordUpdated, - }), + onClick: () => { + window.Whisper.events.trigger('showPasswordDialog', { + action: 'change', + onSuccess: this.onPasswordUpdated, + }); + }, confirmationDialogParams: undefined, }, { @@ -564,11 +566,12 @@ export class SettingsView extends React.Component { buttonText: window.i18n('removePassword'), buttonColor: SessionButtonColor.Danger, }, - onClick: () => - window.showPasswordDialog({ + onClick: () => { + window.Whisper.events.trigger('showPasswordDialog', { action: 'remove', onSuccess: this.onPasswordUpdated, - }), + }); + }, confirmationDialogParams: undefined, }, ]; diff --git a/ts/window.d.ts b/ts/window.d.ts index 759408580..f3f532cf1 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -81,8 +81,6 @@ declare global { setSettingValue: any; shortenPubkey: (pubKey: string) => string; showEditProfileDialog: any; - showPasswordDialog: any; - showSeedDialog: any; storage: any; textsecure: LibTextsecure; toggleLinkPreview: any;