From d54aedcefa8d7e9842d168f4fbb8c01c6da7837d Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 23 May 2018 12:15:46 -0700 Subject: [PATCH] A few fixes for the contact detail screen (#2374) * Only show 'send message' on contact detail when user has account * Make contact detail headers visible in dark mode * Fix vertical scrolling for very large contact in detail pane * Fix a couple comment typos --- _locales/en/messages.json | 2 +- js/views/conversation_view.js | 5 +++-- js/views/message_view.js | 25 ++++++++++++++++++++----- stylesheets/_conversation.scss | 4 ++++ stylesheets/android-dark.scss | 6 ++++++ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 0e7649514c..8f641d683a 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -751,7 +751,7 @@ }, "notificationMostRecent": { "message": "Most recent:", - "description": "Displayed in notifications when setting is 'name and message' and " + "description": "Displayed in notifications when setting is 'name and message' and more than one message is waiting" }, "messageNotSent": { "message": "Message not sent.", diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index f45ba86dc3..713ff98a28 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -1007,19 +1007,20 @@ this.listenBack(view); }, - showContactDetail(contact) { + showContactDetail({ contact, hasSignalAccount }) { const regionCode = storage.get('regionCode'); const { contactSelector } = Signal.Types.Contact; const { getAbsoluteAttachmentPath } = window.Signal.Migrations; const view = new Whisper.ReactWrapperView({ Component: Signal.Components.ContactDetail, + className: 'contact-detail-pane panel', props: { contact: contactSelector(contact, { regionCode, getAbsoluteAttachmentPath, }), - hasSignalAccount: true, + hasSignalAccount, onSendMessage: () => { const number = contact.number && contact.number[0] && contact.number[0].value; diff --git a/js/views/message_view.js b/js/views/message_view.js index 22304234fd..417b898052 100644 --- a/js/views/message_view.js +++ b/js/views/message_view.js @@ -457,15 +457,27 @@ contact.number && contact.number[0] && contact.number[0].value; const haveConversation = number && Boolean(window.ConversationController.get(number)); - const hasLocalSignalAccount = number && haveConversation; + const hasLocalSignalAccount = + this.contactHasSignalAccount || (number && haveConversation); + + // We store this value on this. because a re-render shouldn't kick off another + // profile check, going to the web. + this.contactHasSignalAccount = hasLocalSignalAccount; const onSendMessage = number ? () => { this.model.trigger('open-conversation', number); } : null; - const onOpenContact = () => { - this.model.trigger('show-contact-detail', contact); + const onOpenContact = async () => { + // First let's finish our check with the central server to see if this user has + // a signal account. Then we won't have to do it a second time for the detail + // screen. + await this.checkingProfile; + this.model.trigger('show-contact-detail', { + contact, + hasSignalAccount: this.contactHasSignalAccount, + }); }; const getProps = ({ hasSignalAccount }) => ({ @@ -496,18 +508,21 @@ // If we can't verify a signal account locally, we'll go to the Signal Server. if (number && !hasLocalSignalAccount) { // eslint-disable-next-line more/no-then - window.textsecure.messaging + this.checkingProfile = window.textsecure.messaging .getProfile(number) .then(() => { + this.contactHasSignalAccount = true; + if (!this.contactView) { return; } - this.contactView.update(getProps({ hasSignalAccount: true })); }) .catch(() => { // No account available, or network connectivity problem }); + } else { + this.checkingProfile = Promise.resolve(); } }, isImageWithoutCaption() { diff --git a/stylesheets/_conversation.scss b/stylesheets/_conversation.scss index d408a46d9a..3c22b1bbb6 100644 --- a/stylesheets/_conversation.scss +++ b/stylesheets/_conversation.scss @@ -862,6 +862,10 @@ span.status { margin-top: -2px; } +.contact-detail-pane { + overflow-y: scroll; +} + .contact-detail { text-align: center; max-width: 300px; diff --git a/stylesheets/android-dark.scss b/stylesheets/android-dark.scss index 5e5f6732f2..7b5db886e8 100644 --- a/stylesheets/android-dark.scss +++ b/stylesheets/android-dark.scss @@ -284,6 +284,12 @@ $text-dark_l2: darken($text-dark, 30%); } } + .contact-detail { + .additional-contact .type { + color: rgba(255, 255, 255, 0.5); + } + } + .outgoing .quoted-message { background: rgba(255, 255, 255, 0.38);