Allow primary device to assign local aliases to paired devices

pull/600/head
sachaaaaa 6 years ago
parent d350e4adfb
commit b324421534

@ -955,6 +955,9 @@
"allowPairing": { "allowPairing": {
"message": "Allow Pairing" "message": "Allow Pairing"
}, },
"provideDeviceAlias": {
"message": "Please provide an alias for this paired device"
},
"clear": { "clear": {
"message": "Clear" "message": "Clear"
}, },

@ -285,6 +285,9 @@
<h4>{{ requestAcceptedTitle }}</h4> <h4>{{ requestAcceptedTitle }}</h4>
<p class="secretWords"></p> <p class="secretWords"></p>
<p class="transmissionStatus">Please be patient...</p> <p class="transmissionStatus">Please be patient...</p>
<div id="deviceAliasView" style="display: none;" >
<input id="deviceAlias" type="text" placeholder="Device Alias" required>
</div>
<div class='buttons'> <div class='buttons'>
<button class="ok" style="display: none;">{{ okText }}</button> <button class="ok" style="display: none;">{{ okText }}</button>
</div> </div>

@ -1,4 +1,4 @@
/* global Whisper, i18n, libloki, textsecure */ /* global Whisper, i18n, libloki, textsecure, ConversationController */
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
(function() { (function() {
@ -19,6 +19,7 @@
this.pubKey = null; this.pubKey = null;
this.accepted = false; this.accepted = false;
this.isListening = false; this.isListening = false;
this.success = false;
}, },
events: { events: {
'click #startPairing': 'startReceivingRequests', 'click #startPairing': 'startReceivingRequests',
@ -48,6 +49,13 @@
this.showView(); this.showView();
}, },
stopReceivingRequests() { stopReceivingRequests() {
if (this.success) {
const deviceAlias = this.$('#deviceAlias')[0].value.trim();
const conv = ConversationController.get(this.pubKey);
if (conv) {
conv.setNickname(deviceAlias);
}
}
this.trigger('stopReceivingRequests'); this.trigger('stopReceivingRequests');
this.reset(); this.reset();
this.showView(); this.showView();
@ -69,11 +77,22 @@
}, },
transmisssionCB(errors) { transmisssionCB(errors) {
if (!errors) { if (!errors) {
this.$('.transmissionStatus').text(i18n('sent')); this.$('.transmissionStatus').text(i18n('provideDeviceAlias'));
this.$('#deviceAliasView').show();
this.$('#deviceAlias').on('keydown', (e) => {
if (e.target.value.trim()) {
this.$('.requestAcceptedView .ok').removeAttr('disabled');
} else { } else {
this.$('.transmissionStatus').text(errors); this.$('.requestAcceptedView .ok').attr('disabled', true);
} }
});
this.$('.requestAcceptedView .ok').show(); this.$('.requestAcceptedView .ok').show();
this.$('.requestAcceptedView .ok').attr('disabled', true);
this.success = true;
} else {
this.$('.transmissionStatus').text(errors);
this.$('.requestAcceptedView .ok').show();
}
}, },
skipDevice() { skipDevice() {
this.trigger('devicePairingRequestRejected', this.pubKey); this.trigger('devicePairingRequestRejected', this.pubKey);
@ -99,8 +118,13 @@
if (pubKeys && pubKeys.length > 0) { if (pubKeys && pubKeys.length > 0) {
this.$('#pairedPubKeys').empty(); this.$('#pairedPubKeys').empty();
pubKeys.forEach(x => { pubKeys.forEach(x => {
let deviceAlias = 'Paired Device';
const secretWords = window.mnemonic.pubkey_to_secret_words(x); const secretWords = window.mnemonic.pubkey_to_secret_words(x);
this.$('#pairedPubKeys').append(`<li>(${secretWords})</li>`); const conv = ConversationController.get(x);
if (conv) {
deviceAlias = conv.getNickname();
}
this.$('#pairedPubKeys').append(`<li>${deviceAlias} (${secretWords})</li>`);
}); });
} }
} else if (this.accepted) { } else if (this.accepted) {

Loading…
Cancel
Save