Skip to content
Snippets Groups Projects
Unverified Commit 76b9e8f9 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

chatview: bufferize messages during chatview creation

Change-Id: I3cf17e7e508c0abf27400839bedf60e7db3e79b5
Gitlab: #1038
parent 8d988c33
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,15 @@ ...@@ -40,6 +40,15 @@
// Client // Client
#include "utils/files.h" #include "utils/files.h"
struct CppImpl {
struct Interaction {
std::string conv;
uint64_t id;
lrc::api::interaction::Info info;
};
std::vector<Interaction> interactionsBuffer_;
};
struct _ChatView struct _ChatView
{ {
GtkBox parent; GtkBox parent;
...@@ -70,6 +79,9 @@ struct _ChatViewPrivate ...@@ -70,6 +79,9 @@ struct _ChatViewPrivate
gulong webkit_ready; gulong webkit_ready;
gulong webkit_send_text; gulong webkit_send_text;
gulong webkit_drag_drop; gulong webkit_drag_drop;
bool ready_ {false};
CppImpl* cpp_;
}; };
G_DEFINE_TYPE_WITH_PRIVATE(ChatView, chat_view, GTK_TYPE_BOX); G_DEFINE_TYPE_WITH_PRIVATE(ChatView, chat_view, GTK_TYPE_BOX);
...@@ -452,8 +464,6 @@ print_text_recording(ChatView *self) ...@@ -452,8 +464,6 @@ print_text_recording(ChatView *self)
*(*priv->accountInfo_)->conversationModel, *(*priv->accountInfo_)->conversationModel,
priv->conversation_->interactions priv->conversation_->interactions
); );
QObject::disconnect(priv->new_interaction_connection);
} }
static void static void
...@@ -472,14 +482,12 @@ webkit_chat_container_ready(ChatView* self) ...@@ -472,14 +482,12 @@ webkit_chat_container_ready(ChatView* self)
print_text_recording(self); print_text_recording(self);
load_participants_images(self); load_participants_images(self);
priv->new_interaction_connection = QObject::connect( priv->ready_ = true;
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::newInteraction, for (const auto& interaction: priv->cpp_->interactionsBuffer_) {
[self, priv](const std::string& uid, uint64_t interactionId, lrc::api::interaction::Info interaction) { if (interaction.conv == priv->conversation_->uid) {
if (!priv->conversation_) return; print_interaction_to_buffer(self, interaction.id, interaction.info);
if (uid == priv->conversation_->uid) { }
print_interaction_to_buffer(self, interactionId, interaction);
} }
});
priv->update_interaction_connection = QObject::connect( priv->update_interaction_connection = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::interactionStatusUpdated, &*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::interactionStatusUpdated,
...@@ -641,6 +649,20 @@ build_chat_view(ChatView* self) ...@@ -641,6 +649,20 @@ build_chat_view(ChatView* self)
self self
); );
priv->new_interaction_connection = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::newInteraction,
[self, priv](const std::string& uid, uint64_t interactionId, lrc::api::interaction::Info interaction) {
if (!priv->conversation_) return;
if (!priv->ready_ && priv->cpp_) {
priv->cpp_->interactionsBuffer_.emplace_back(CppImpl::Interaction {
uid, interactionId, interaction});
} else if (uid == priv->conversation_->uid) {
print_interaction_to_buffer(self, interactionId, interaction);
}
});
priv->cpp_ = new CppImpl();
if (webkit_chat_container_is_ready(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container))) if (webkit_chat_container_is_ready(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container)))
webkit_chat_container_ready(self); webkit_chat_container_ready(self);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment