Commit 8ab4a814 authored by Sébastien Blin's avatar Sébastien Blin Committed by Philippe Gorley

chatview: fix add button and invitation visibility

Change-Id: I3b1abc6432901caec56f6d6147bfefa1de844844
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 162eb0f4
......@@ -542,12 +542,12 @@ chat_view_new (WebKitChatContainer* webkit_chat_container,
}
void
chat_view_update_temporary(ChatView* self, bool newValue)
chat_view_update_temporary(ChatView* self, bool showAddButton, bool showInvitation)
{
g_return_if_fail(IS_CHAT_VIEW(self));
auto priv = CHAT_VIEW_GET_PRIVATE(self);
priv->isTemporary_ = newValue;
priv->isTemporary_ = showAddButton;
if (!priv->isTemporary_) {
gtk_widget_hide(priv->button_add_to_conversations);
}
......@@ -562,7 +562,7 @@ chat_view_update_temporary(ChatView* self, bool newValue)
if (bestName.empty())
bestName = contactInfo.profileInfo.uri;
webkit_chat_container_set_invitation(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
newValue,
showInvitation,
bestName);
} catch (const std::out_of_range&) {
// ContactModel::getContact() exception
......
......@@ -56,7 +56,7 @@ GtkWidget *chat_view_new (WebKitChatContainer* view,
lrc::api::conversation::Info* conversation);
lrc::api::conversation::Info chat_view_get_conversation(ChatView*);
bool chat_view_get_temporary(ChatView*);
void chat_view_update_temporary(ChatView*, bool);
void chat_view_update_temporary(ChatView*, bool, bool);
void chat_view_set_header_visible(ChatView*, gboolean);
G_END_DECLS
......@@ -873,9 +873,10 @@ CppImpl::displayCurrentCallView(lrc::api::conversation::Info conversation)
auto contactUri = chatViewConversation_->participants.front();
auto contactInfo = accountContainer_->info.contactModel->getContact(contactUri);
if (auto chat_view = current_call_view_get_chat_view(CURRENT_CALL_VIEW(new_view))) {
auto isPending = contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING;
chat_view_update_temporary(CHAT_VIEW(chat_view),
contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING
|| contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY);
isPending || contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY,
isPending);
}
} catch(...) { }
......@@ -1370,9 +1371,10 @@ CppImpl::slotNewConversation(const std::string& uid)
try {
auto contactUri = chatViewConversation_->participants.front();
auto contactInfo = accountContainer_->info.contactModel->getContact(contactUri);
auto isPending = contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING;
chat_view_update_temporary(CHAT_VIEW(gtk_bin_get_child(GTK_BIN(widgets->frame_call))),
contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING
|| contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY);
isPending || contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY,
isPending);
} catch(...) { }
}
}
......@@ -1403,12 +1405,18 @@ CppImpl::slotShowChatView(const std::string& id, lrc::api::conversation::Info or
current_item.uid = "-1";
if (IS_CHAT_VIEW(old_view))
current_item = chat_view_get_conversation(CHAT_VIEW(old_view));
// Do not show a conversation without any participants
if (origin.participants.empty()) return;
auto firstContactUri = origin.participants.front();
auto contactInfo = accountContainer_->info.contactModel->getContact(firstContactUri);
// change view if necessary or just update temporary
if (current_item.uid != origin.uid) {
if (origin.participants.empty()) return;
auto firstContactUri = origin.participants.front();
auto contactInfo = accountContainer_->info.contactModel->getContact(firstContactUri);
if (contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING && current_item.uid != "-1") return;
changeView(CHAT_VIEW_TYPE, origin);
} else {
auto isPending = contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING;
chat_view_update_temporary(CHAT_VIEW(old_view),
isPending || contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY,
isPending);
}
}
......
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