Added menu options to set, change and remove password.

pull/77/head
Mikunj 6 years ago
parent f53bec38a5
commit 26ba553e6a

@ -1692,5 +1692,17 @@
},
"unlock": {
"message": "Unlock"
},
"setPassword": {
"message": "Set Password",
"description": "Button action that the user can click to set a password"
},
"changePassword": {
"message": "Set Password",
"description": "Button action that the user can click to change a password"
},
"removePassword": {
"message": "Set Password",
"description": "Button action that the user can click to remove a password"
}
}

@ -610,6 +610,12 @@
window.log.error('Error showing PoW cog');
}
});
Whisper.events.on('password-updated', () => {
if (appView && appView.inboxView) {
appView.inboxView.trigger('password-updated');
}
});
}
window.getSyncRequest = () =>

@ -6,6 +6,7 @@
/* global Whisper: false */
/* global textsecure: false */
/* global clipboard: false */
/* global Signal: false */
// eslint-disable-next-line func-names
(function() {
@ -106,6 +107,8 @@
el: this.$('.main-header-placeholder'),
items: this.getMainHeaderItems(),
});
this.onPasswordUpdated();
this.on('password-updated', () => this.onPasswordUpdated());
this.conversation_stack = new Whisper.ConversationStack({
el: this.$('.conversation-stack'),
@ -340,8 +343,25 @@
this._mainHeaderItem('editDisplayName', () => {
window.Whisper.events.trigger('onEditProfile');
}),
...this.passwordHeaderItems || [],
];
},
async onPasswordUpdated() {
const hasPassword = await Signal.Data.getPasswordHash();
const items = this.getMainHeaderItems();
if (hasPassword) {
items.push(
this._mainHeaderItem('changePassword'),
this._mainHeaderItem('removePassword')
);
} else {
items.push(
this._mainHeaderItem('setPassword')
);
}
this.mainHeaderView.updateItems(items);
},
_mainHeaderItem(textKey, onClick) {
return {
id: textKey,

@ -1,4 +1,4 @@
/* global Whisper, textsecure, ConversationController, Signal, i18n */
/* global Whisper, textsecure, ConversationController, Signal */
// eslint-disable-next-line func-names
(function() {
@ -14,8 +14,6 @@
'click .copy-key': 'onCopyKey',
},
initialize(options) {
this.items = options.items || [];
this.ourNumber = textsecure.storage.user.getNumber();
const me = ConversationController.getOrCreate(this.ourNumber, 'private');
@ -34,14 +32,19 @@
this.$content = this.$('.main-header-content-wrapper');
this.$content.hide();
this.registerCallbacks();
this.updateItems(options.items);
},
registerCallbacks() {
this.items.forEach(item => {
updateItems(items) {
this.$content.html('');
(items || []).forEach(item => {
// Add the item
this.$content.append(`<div role='button' id='${item.id}'>${item.text}</div>`);
// Register its callback
if (item.onClick) {
this.$(`#${item.id}`).click(item.onClick);
}
})
});
},
render_attributes() {
return {

@ -55,6 +55,7 @@ window.setPassword = (passPhrase, oldPhrase) => new Promise((resolve, reject) =>
if (error) {
return reject(error);
}
Whisper.events.trigger('password-updated');
return resolve();
});
ipc.send('set-password', passPhrase, oldPhrase);

Loading…
Cancel
Save