Make identity key screen show up immediately

This commit is contained in:
Scott Nonnenberg 2019-08-09 16:35:09 -07:00
parent c39d5a811a
commit e4d2e28ec4
2 changed files with 28 additions and 25 deletions

View file

@ -20,18 +20,21 @@
this.theirKey = options.newKey; this.theirKey = options.newKey;
} }
this.loadTheirKey();
this.loadOurKey();
this.render();
if (options.onLoad) {
options.onLoad();
}
this.loadKeys().then(() => { this.loadKeys().then(() => {
this.listenTo(this.model, 'change', this.render); this.listenTo(this.model, 'change', this.render);
if (options.onLoad) {
options.onLoad();
}
}); });
}, },
loadKeys() { async loadKeys() {
return Promise.all([this.loadTheirKey(), this.loadOurKey()]) await this.generateSecurityNumber();
.then(this.generateSecurityNumber.bind(this)) this.render();
.then(this.render.bind(this));
// .then(this.makeQRCode.bind(this));
}, },
makeQRCode() { makeQRCode() {
// Per Lilia: We can't turn this on until it generates a Latin1 string, as is // Per Lilia: We can't turn this on until it generates a Latin1 string, as is
@ -41,18 +44,12 @@
); );
}, },
loadTheirKey() { loadTheirKey() {
return textsecure.storage.protocol const item = textsecure.storage.protocol.identityKeys[this.model.id];
.loadIdentityKey(this.model.id) this.theirKey = item ? item.publicKey : null;
.then(theirKey => {
this.theirKey = theirKey;
});
}, },
loadOurKey() { loadOurKey() {
return textsecure.storage.protocol const item = textsecure.storage.protocol.identityKeys[this.ourNumber];
.loadIdentityKey(this.ourNumber) this.ourKey = item ? item.publicKey : null;
.then(ourKey => {
this.ourKey = ourKey;
});
}, },
generateSecurityNumber() { generateSecurityNumber() {
return new libsignal.FingerprintGenerator(5200) return new libsignal.FingerprintGenerator(5200)
@ -113,8 +110,14 @@
render_attributes() { render_attributes() {
const s = this.securityNumber; const s = this.securityNumber;
const chunks = []; const chunks = [];
for (let i = 0; i < s.length; i += 5) { if (s) {
chunks.push(s.substring(i, i + 5)); for (let i = 0; i < s.length; i += 5) {
chunks.push(s.substring(i, i + 5));
}
} else {
for (let i = 0; i < 12; i += 1) {
chunks.push('XXXXX');
}
} }
const name = this.model.getTitle(); const name = this.model.getTitle();
const yourSafetyNumberWith = i18n( const yourSafetyNumberWith = i18n(

View file

@ -711,7 +711,7 @@
"rule": "jQuery-$(", "rule": "jQuery-$(",
"path": "js/views/key_verification_view.js", "path": "js/views/key_verification_view.js",
"line": " new QRCode(this.$('.qr')[0]).makeCode(", "line": " new QRCode(this.$('.qr')[0]).makeCode(",
"lineNumber": 39, "lineNumber": 42,
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2019-07-31T00:19:18.696Z", "updated": "2019-07-31T00:19:18.696Z",
"reasonDetail": "Hardcoded selector" "reasonDetail": "Hardcoded selector"
@ -720,7 +720,7 @@
"rule": "jQuery-wrap(", "rule": "jQuery-wrap(",
"path": "js/views/key_verification_view.js", "path": "js/views/key_verification_view.js",
"line": " dcodeIO.ByteBuffer.wrap(this.ourKey).toString('base64')", "line": " dcodeIO.ByteBuffer.wrap(this.ourKey).toString('base64')",
"lineNumber": 40, "lineNumber": 43,
"reasonCategory": "falseMatch", "reasonCategory": "falseMatch",
"updated": "2019-07-31T00:19:18.696Z" "updated": "2019-07-31T00:19:18.696Z"
}, },
@ -728,7 +728,7 @@
"rule": "jQuery-insertBefore(", "rule": "jQuery-insertBefore(",
"path": "js/views/key_verification_view.js", "path": "js/views/key_verification_view.js",
"line": " dialog.$el.insertBefore(this.el);", "line": " dialog.$el.insertBefore(this.el);",
"lineNumber": 75, "lineNumber": 72,
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2019-07-31T00:19:18.696Z", "updated": "2019-07-31T00:19:18.696Z",
"reasonDetail": "Known DOM elements" "reasonDetail": "Known DOM elements"
@ -737,7 +737,7 @@
"rule": "jQuery-$(", "rule": "jQuery-$(",
"path": "js/views/key_verification_view.js", "path": "js/views/key_verification_view.js",
"line": " this.$('button.verify').attr('disabled', true);", "line": " this.$('button.verify').attr('disabled', true);",
"lineNumber": 79, "lineNumber": 76,
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2019-07-31T00:19:18.696Z", "updated": "2019-07-31T00:19:18.696Z",
"reasonDetail": "Hardcoded selector" "reasonDetail": "Hardcoded selector"
@ -746,7 +746,7 @@
"rule": "jQuery-$(", "rule": "jQuery-$(",
"path": "js/views/key_verification_view.js", "path": "js/views/key_verification_view.js",
"line": " this.$('button.verify').removeAttr('disabled');", "line": " this.$('button.verify').removeAttr('disabled');",
"lineNumber": 110, "lineNumber": 107,
"reasonCategory": "usageTrusted", "reasonCategory": "usageTrusted",
"updated": "2019-07-31T00:19:18.696Z", "updated": "2019-07-31T00:19:18.696Z",
"reasonDetail": "Hardcoded selector" "reasonDetail": "Hardcoded selector"