Nest key verification inside conflict dialogs

// FREEBIE
This commit is contained in:
lilia 2016-03-23 12:33:50 -07:00
parent c4fcbd8cbe
commit 6fe9c3f964
8 changed files with 123 additions and 122 deletions

View file

@ -162,7 +162,7 @@
var our_number = textsecure.storage.user.getNumber();
textsecure.storage.axolotl.getIdentityKey(their_number).then(function(their_key) {
textsecure.storage.axolotl.getIdentityKey(our_number).then(function(our_key) {
var view = new Whisper.KeyVerificationView({
var view = new Whisper.KeyVerificationPanelView({
model: { their_key: their_key, your_key: our_key }
}).render();
this.listenBack(view);

View file

@ -11,42 +11,48 @@
className: 'key-conflict-dialogue clearfix',
initialize: function(options) {
this.contact = options.contact;
this.conflict = options.conflict;
this.conversation = options.conversation;
textsecure.storage.axolotl.getIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) {
this.your_key = our_key;
this.render();
}.bind(this));
textsecure.storage.axolotl.getIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) {
var view = new Whisper.KeyVerificationView({
model: {
their_key : this.model.identityKey,
your_key : our_key
}
});
view.render().$el.appendTo(this.$('.keys'));
}.bind(this));
},
events: {
'click .conflict': 'showDialog',
'click .cancel' : 'cancel',
'click .verify' : 'triggerVerify',
'click .showKeys': 'showKeys',
'click .hideKeys': 'hideKeys',
'click .resolve' : 'resolve'
},
triggerVerify: function() {
this.trigger('verify', {identityKey: this.model.identityKey});
hideKeys: function() {
this.$('.keys, .hideKeys').hide();
this.$('.showKeys').show();
},
showKeys: function() {
this.$('.keys, .hideKeys').show();
this.$('.showKeys').hide();
},
resolve: function() {
this.trigger('resolve');
this.remove();
this.conversation.resolveConflicts(this.model);
},
showDialog: function() {
this.$('.conflict').hide();
this.$('.cancel, .content').show();
},
cancel: function() {
this.$('.cancel, .content').hide();
this.$('.conflict').show();
},
render_attributes: function() {
return {
name : this.contact.getTitle(),
avatar : this.contact.getAvatar(),
conflict : this.conflict,
verify : i18n('verify'),
cancel : i18n('cancel'),
conflict : this.model,
newIdentity : i18n('newIdentity'),
message : i18n('identityChanged'),
resolve : i18n('acceptNewKey'),
verifyContact: i18n('verifyContact')
showKeys : i18n('showMore'),
hideKeys : i18n('showLess')
};
}
});

View file

@ -6,8 +6,8 @@
window.Whisper = window.Whisper || {};
Whisper.KeyVerificationView = Whisper.View.extend({
className: 'key-verification panel',
templateName: 'key-verification',
className: 'key-verification',
templateName: 'key_verification',
events: {
'click .back': 'goBack'
},
@ -36,4 +36,8 @@
};
}
});
Whisper.KeyVerificationPanelView = Whisper.KeyVerificationView.extend({
className: 'key-verification panel',
templateName: 'key_verification_panel',
});
})();

View file

@ -43,19 +43,6 @@
goBack: function() {
this.trigger('back');
},
verify: function(their_key) {
textsecure.storage.axolotl.getIdentityKey(textsecure.storage.user.getNumber()).then(function(our_key) {
var view = new Whisper.KeyVerificationView({
model: { their_key: their_key, your_key: our_key }
});
this.$el.hide();
view.render().$el.insertAfter(this.el);
this.listenTo(view, 'back', function() {
view.remove();
this.$el.show();
}.bind(this));
}.bind(this));
},
contacts: function() {
if (this.model.isIncoming()) {
var number = this.model.get('source');
@ -83,14 +70,6 @@
conversation: this.conversation
}).render();
this.$('.conflicts').append(view.el);
this.listenTo(view, 'verify', function(data) {
this.verify(conflict.identityKey);
});
/*
this.listenTo(view, 'resolve', function() {
this.render();
});
*/
},
render: function() {
this.errors = _.groupBy(this.model.get('errors'), 'number');