im: remove bestID if equal to bestName

In order to reduce information redundancy and possible confusion, the
bestID of the contact we are currently talking to is hidden if it is
equal to its bestName. This one shows a different name only if we
received the contact VCard and its profile name is different than its
registered name.

Moreover, in case we only display the bestName, we center it
vertically for a cleaner appearance.

Change-Id: I29aa32d4c8394fded057c18f2b8c5446d3cfa11f
Reviewed-by: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
diff --git a/src/ConversationVC.mm b/src/ConversationVC.mm
index 91be13d..23cf157 100644
--- a/src/ConversationVC.mm
+++ b/src/ConversationVC.mm
@@ -64,6 +64,9 @@
     __unsafe_unretained IBOutlet NSLayoutConstraint* sentContactRequestWidth;
     __unsafe_unretained IBOutlet NSButton* sentContactRequestButton;
     IBOutlet MessagesVC* messagesViewVC;
+
+    IBOutlet NSLayoutConstraint* titleHoverButtonConstraint;
+    IBOutlet NSLayoutConstraint* titleTopConstraint;
 }
 
 
@@ -119,11 +122,16 @@
                          }
 
                          BOOL isSMultipleCM = (contactMethods.length() > 1);
+                         BOOL hideCMPopupButton = !isSMultipleCM && (contactMethods.first()->bestId() == contactMethods.first()->bestName());
 
                          [contactMethodsPopupButton setEnabled:isSMultipleCM];
                          [contactMethodsPopupButton setBordered:isSMultipleCM];
+                         [contactMethodsPopupButton setHidden:hideCMPopupButton];
                          [[contactMethodsPopupButton cell] setArrowPosition: !isSMultipleCM ? NSPopUpNoArrow : NSPopUpArrowAtBottom];
 
+                         [titleHoverButtonConstraint setActive:hideCMPopupButton];
+                         [titleTopConstraint setActive:!hideCMPopupButton];
+
                          [emptyConversationPlaceHolder setHidden:NO];
                          // Select first cm
                          [contactMethodsPopupButton selectItemAtIndex:0];
@@ -260,12 +268,12 @@
 
     [self updateSendButtonVisibility];
 
-    [conversationTitle setStringValue:selectedContactMethod->primaryName().toNSString()];
+    [conversationTitle setStringValue:selectedContactMethod->bestName().toNSString()];
     QObject::disconnect(contactMethodChanged);
     contactMethodChanged = QObject::connect(selectedContactMethod,
                                             &ContactMethod::changed,
                                             [self] {
-                                                [conversationTitle setStringValue:selectedContactMethod->primaryName().toNSString()];
+                                                [conversationTitle setStringValue:selectedContactMethod->bestName().toNSString()];
                                                 [self updateSendButtonVisibility];
                                             });