diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 75b2be0db..58cc6bb23 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -955,6 +955,9 @@ "allowPairing": { "message": "Allow Pairing" }, + "provideDeviceAlias": { + "message": "Please provide an alias for this paired device" + }, "showPairingWordsTitle": { "message": "Pairing Secret Words" }, diff --git a/background.html b/background.html index bf21c6aec..ecfe74afa 100644 --- a/background.html +++ b/background.html @@ -285,6 +285,9 @@
Please be patient...
+ diff --git a/js/views/device_pairing_dialog_view.js b/js/views/device_pairing_dialog_view.js index c4e339c11..b8fb7fba9 100644 --- a/js/views/device_pairing_dialog_view.js +++ b/js/views/device_pairing_dialog_view.js @@ -1,4 +1,4 @@ -/* global Whisper, i18n, libloki, textsecure */ +/* global Whisper, i18n, libloki, textsecure, ConversationController */ // eslint-disable-next-line func-names (function() { @@ -19,6 +19,7 @@ this.pubKey = null; this.accepted = false; this.isListening = false; + this.success = false; }, events: { 'click #startPairing': 'startReceivingRequests', @@ -48,6 +49,13 @@ this.showView(); }, 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.reset(); this.showView(); @@ -69,11 +77,22 @@ }, transmisssionCB(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 { + this.$('.requestAcceptedView .ok').attr('disabled', true); + } + }); + this.$('.requestAcceptedView .ok').show(); + this.$('.requestAcceptedView .ok').attr('disabled', true); + this.success = true; } else { this.$('.transmissionStatus').text(errors); + this.$('.requestAcceptedView .ok').show(); } - this.$('.requestAcceptedView .ok').show(); }, skipDevice() { this.trigger('devicePairingRequestRejected', this.pubKey); @@ -99,8 +118,15 @@ if (pubKeys && pubKeys.length > 0) { this.$('#pairedPubKeys').empty(); pubKeys.forEach(x => { + let deviceAlias = 'Paired Device'; const secretWords = window.mnemonic.pubkey_to_secret_words(x); - this.$('#pairedPubKeys').append(`