Commit f11c9f30 authored by Sébastien Blin's avatar Sébastien Blin

conversationsview: always retrieve the correct best id

We used the registeredname as the best id, but it's not the case, we
need to get the best id from the registeredname or the uri.
note, remove useless TODO linked to the quality.

Change-Id: I1339d20ee1e4dd96c5c53b932b1fe262b6a53783
Reviewed-by: default avatarNicolas Jäger <nicolas.jager@savoirfairelinux.com>
parent b2105538
......@@ -306,10 +306,11 @@ update_contact_methods(ChatView *self)
if (!priv->conversation_) return;
auto contactUri = priv->conversation_->participants.front();
auto contactInfo = priv->accountContainer_->info.contactModel->getContact(contactUri);
if (contactInfo.profileInfo.alias == contactInfo.registeredName) {
auto bestId = std::string(contactInfo.registeredName).empty() ? contactInfo.profileInfo.uri : contactInfo.registeredName;
if (contactInfo.profileInfo.alias == bestId) {
gtk_widget_hide(priv->label_cm);
} else {
gtk_label_set_text(GTK_LABEL(priv->label_cm), contactInfo.registeredName.c_str());
gtk_label_set_text(GTK_LABEL(priv->label_cm), bestId.c_str());
gtk_widget_show(priv->label_cm);
}
......
......@@ -121,23 +121,26 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gchar *lastInteraction;
gchar *text;
gchar *uid;
gchar *uri;
gtk_tree_model_get (model, iter,
0 /* col# */, &uid /* data */,
1 /* col# */, &alias /* data */,
2 /* col# */, &registeredName /* data */,
4 /* col# */, &lastInteraction /* data */,
2 /* col# */, &uri /* data */,
3 /* col# */, &registeredName /* data */,
5 /* col# */, &lastInteraction /* data */,
-1);
auto bestId = std::string(registeredName).empty() ? uri: registeredName;
if (std::string(alias).empty()) {
// For conversations with contacts with no alias
text = g_markup_printf_escaped(
"<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>",
registeredName,
bestId,
lastInteraction
);
} else if (std::string(alias) == std::string(registeredName)
|| std::string(registeredName).empty() || std::string(uid).empty()) {
} else if (std::string(alias) == std::string(bestId)
|| std::string(bestId).empty() || std::string(uid).empty()) {
// For temporary item
text = g_markup_printf_escaped(
"<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>",
......@@ -149,13 +152,14 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
text = g_markup_printf_escaped(
"<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>",
alias,
registeredName,
bestId,
lastInteraction
);
}
g_object_set(G_OBJECT(cell), "markup", text, NULL);
g_free(uid);
g_free(uri);
g_free(alias);
g_free(registeredName);
}
......@@ -222,7 +226,8 @@ static GtkTreeModel*
create_and_fill_model(ConversationsView *self)
{
auto priv = CONVERSATIONS_VIEW_GET_PRIVATE(self);
auto store = gtk_list_store_new (5 /* # of cols */ ,
auto store = gtk_list_store_new (6 /* # of cols */ ,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
......@@ -245,9 +250,10 @@ create_and_fill_model(ConversationsView *self)
gtk_list_store_set (store, &iter,
0 /* col # */ , conversation.uid.c_str() /* celldata */,
1 /* col # */ , alias.c_str() /* celldata */,
2 /* col # */ , contactInfo.registeredName.c_str() /* celldata */,
3 /* col # */ , contactInfo.profileInfo.avatar.c_str() /* celldata */,
4 /* col # */ , lastMessage.c_str() /* celldata */,
2 /* col # */ , contactInfo.profileInfo.uri.c_str() /* celldata */,
3 /* col # */ , contactInfo.registeredName.c_str() /* celldata */,
4 /* col # */ , contactInfo.profileInfo.avatar.c_str() /* celldata */,
5 /* col # */ , lastMessage.c_str() /* celldata */,
-1 /* end */);
}
......
......@@ -378,7 +378,6 @@ set_quality(Call *call, gboolean auto_quality_on, double desired_quality)
static void
autoquality_toggled(GtkToggleButton *button, CurrentCallView *self)
{
// TODO
g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
......@@ -406,7 +405,6 @@ autoquality_toggled(GtkToggleButton *button, CurrentCallView *self)
static void
quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value, CurrentCallView *self)
{
// TODO
g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment