Let key verification view lazy-load keys
// FREEBIE
This commit is contained in:
parent
fe209a2f41
commit
c16e80c5e4
4 changed files with 48 additions and 36 deletions
|
@ -196,21 +196,10 @@
|
||||||
|
|
||||||
verifyIdentity: function() {
|
verifyIdentity: function() {
|
||||||
if (this.model.isPrivate()) {
|
if (this.model.isPrivate()) {
|
||||||
var their_number = this.model.id;
|
|
||||||
var our_number = textsecure.storage.user.getNumber();
|
|
||||||
textsecure.storage.protocol.loadIdentityKey(their_number).then(function(their_key) {
|
|
||||||
textsecure.storage.protocol.loadIdentityKey(our_number).then(function(our_key) {
|
|
||||||
var view = new Whisper.KeyVerificationPanelView({
|
var view = new Whisper.KeyVerificationPanelView({
|
||||||
model: {
|
model: { their_number: this.model.id }
|
||||||
your_number: our_number,
|
|
||||||
their_number: their_number,
|
|
||||||
their_key: their_key,
|
|
||||||
your_key: our_key
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.listenBack(view);
|
this.listenBack(view);
|
||||||
}.bind(this));
|
|
||||||
}.bind(this));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,14 @@
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.contact = options.contact;
|
this.contact = options.contact;
|
||||||
this.conversation = options.conversation;
|
this.conversation = options.conversation;
|
||||||
var our_number = textsecure.storage.user.getNumber();
|
|
||||||
textsecure.storage.protocol.loadIdentityKey(our_number).then(function(our_key) {
|
|
||||||
this.your_key = our_key;
|
|
||||||
this.render();
|
this.render();
|
||||||
var view = new Whisper.KeyVerificationView({
|
var view = new Whisper.KeyVerificationView({
|
||||||
model: {
|
model: {
|
||||||
your_number: our_number,
|
|
||||||
their_number: this.model.number,
|
their_number: this.model.number,
|
||||||
their_key : this.model.identityKey,
|
their_key : this.model.identityKey,
|
||||||
your_key : our_key
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.$el.appendTo(this.$('.keys'));
|
view.$el.appendTo(this.$('.keys'));
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'click .showKeys': 'showKeys',
|
'click .showKeys': 'showKeys',
|
||||||
|
|
|
@ -37,12 +37,41 @@
|
||||||
className: 'key-verification',
|
className: 'key-verification',
|
||||||
templateName: 'key_verification',
|
templateName: 'key_verification',
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
Promise.all([
|
||||||
|
this.loadTheirKey(),
|
||||||
|
this.loadOurKey(),
|
||||||
|
]).then(function() {
|
||||||
this.render();
|
this.render();
|
||||||
/*
|
/*
|
||||||
this.$('.securityNumber').append(
|
this.$('.securityNumber').append(
|
||||||
new SecurityNumberView({model: this.model}).el
|
new SecurityNumberView({model: this.model}).el
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
setOurKey: function(our_key) {
|
||||||
|
this.model.your_key = our_key;
|
||||||
|
},
|
||||||
|
setTheirKey: function(their_key) {
|
||||||
|
this.model.their_key = their_key;
|
||||||
|
},
|
||||||
|
loadTheirKey: function() {
|
||||||
|
if (this.model.their_key) {
|
||||||
|
return Promise.resolve(this.model.their_key);
|
||||||
|
} else {
|
||||||
|
return textsecure.storage.protocol.loadIdentityKey(
|
||||||
|
this.model.their_number
|
||||||
|
).then(this.setTheirKey.bind(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loadOurKey: function() {
|
||||||
|
if (this.model.your_key) {
|
||||||
|
return Promise.resolve(this.model.your_key);
|
||||||
|
} else {
|
||||||
|
return textsecure.storage.protocol.loadIdentityKey(
|
||||||
|
textsecure.storage.user.getNumber()
|
||||||
|
).then(this.setOurKey.bind(this));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
splitKey: function(key) {
|
splitKey: function(key) {
|
||||||
// key is an array buffer
|
// key is an array buffer
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
model: conflict,
|
model: conflict,
|
||||||
contact: contact,
|
contact: contact,
|
||||||
conversation: this.conversation
|
conversation: this.conversation
|
||||||
}).render();
|
});
|
||||||
this.$('.conflicts').append(view.el);
|
this.$('.conflicts').append(view.el);
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
Loading…
Reference in a new issue