mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-01 12:43:30 +02:00
conversations: respond to needsSyncingSet signal
When the needsSyncingSet signal is caught, we need to update the UI to change filter tab, reload the conversation, etc. Change-Id: I70170d75afa50acad6e79d53fcaeb82752c38e81
This commit is contained in:
parent
8409355e93
commit
0234fc6f94
4 changed files with 129 additions and 94 deletions
|
@ -331,14 +331,14 @@ ConversationsAdapter::onSearchResultUpdated()
|
|||
}
|
||||
|
||||
void
|
||||
ConversationsAdapter::onConversationReady(const QString& convId)
|
||||
ConversationsAdapter::updateConversation(const QString& convId)
|
||||
{
|
||||
// a conversation request has been accepted or a contact has
|
||||
// been added, so select the conversation and notify the UI to:
|
||||
// - switch tabs to the conversation filter tab
|
||||
// - clear search bar
|
||||
lrcInstance_->selectConversation(convId);
|
||||
Q_EMIT conversationReady(convId);
|
||||
lrcInstance_->selectConversation(convId);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -426,51 +426,57 @@ ConversationsAdapter::connectConversationModel()
|
|||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::modelChanged,
|
||||
&ConversationModel::modelChanged,
|
||||
this,
|
||||
&ConversationsAdapter::onModelChanged,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(lrcInstance_->getCurrentAccountInfo().contactModel.get(),
|
||||
&lrc::api::ContactModel::profileUpdated,
|
||||
&ContactModel::profileUpdated,
|
||||
this,
|
||||
&ConversationsAdapter::onProfileUpdated,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::conversationUpdated,
|
||||
&ConversationModel::conversationUpdated,
|
||||
this,
|
||||
&ConversationsAdapter::onConversationUpdated,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::filterChanged,
|
||||
&ConversationModel::filterChanged,
|
||||
this,
|
||||
&ConversationsAdapter::onFilterChanged,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::conversationCleared,
|
||||
&ConversationModel::conversationCleared,
|
||||
this,
|
||||
&ConversationsAdapter::onConversationCleared,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::searchStatusChanged,
|
||||
&ConversationModel::searchStatusChanged,
|
||||
this,
|
||||
&ConversationsAdapter::onSearchStatusChanged,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::searchResultUpdated,
|
||||
&ConversationModel::searchResultUpdated,
|
||||
this,
|
||||
&ConversationsAdapter::onSearchResultUpdated,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::conversationReady,
|
||||
&ConversationModel::conversationReady,
|
||||
this,
|
||||
&ConversationsAdapter::onConversationReady,
|
||||
&ConversationsAdapter::updateConversation,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::needsSyncingSet,
|
||||
this,
|
||||
&ConversationsAdapter::updateConversation,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
convSrcModel_.reset(new ConversationListModel(lrcInstance_));
|
||||
|
|
|
@ -82,7 +82,7 @@ private Q_SLOTS:
|
|||
void onConversationCleared(const QString&);
|
||||
void onSearchStatusChanged(const QString&);
|
||||
void onSearchResultUpdated();
|
||||
void onConversationReady(const QString&);
|
||||
void updateConversation(const QString&);
|
||||
|
||||
void updateConversationFilterData();
|
||||
|
||||
|
|
|
@ -119,85 +119,111 @@ MessagesAdapter::setupChatView(const QString& convUid)
|
|||
}
|
||||
|
||||
void
|
||||
MessagesAdapter::connectConversationModel()
|
||||
{
|
||||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||
|
||||
QObject::disconnect(newInteractionConnection_);
|
||||
QObject::disconnect(interactionRemovedConnection_);
|
||||
QObject::disconnect(interactionStatusUpdatedConnection_);
|
||||
QObject::disconnect(conversationUpdatedConnection_);
|
||||
QObject::disconnect(composingConnection_);
|
||||
|
||||
newInteractionConnection_
|
||||
= QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::newInteraction,
|
||||
[this](const QString& convUid,
|
||||
MessagesAdapter::onNewInteraction(const QString& convUid,
|
||||
const QString& interactionId,
|
||||
const lrc::api::interaction::Info& interaction) {
|
||||
const lrc::api::interaction::Info& interaction)
|
||||
{
|
||||
auto accountId = lrcInstance_->getCurrentAccountId();
|
||||
newInteraction(accountId, convUid, interactionId, interaction);
|
||||
});
|
||||
}
|
||||
|
||||
interactionStatusUpdatedConnection_ = QObject::connect(
|
||||
currentConversationModel,
|
||||
&lrc::api::ConversationModel::interactionStatusUpdated,
|
||||
[this](const QString& convUid,
|
||||
void
|
||||
MessagesAdapter::onInteractionStatusUpdated(const QString& convUid,
|
||||
const QString& interactionId,
|
||||
const lrc::api::interaction::Info& interaction) {
|
||||
const lrc::api::interaction::Info& interaction)
|
||||
{
|
||||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||
currentConversationModel->clearUnreadInteractions(convUid);
|
||||
updateInteraction(*currentConversationModel, interactionId, interaction);
|
||||
});
|
||||
}
|
||||
|
||||
interactionRemovedConnection_
|
||||
= QObject::connect(currentConversationModel,
|
||||
&lrc::api::ConversationModel::interactionRemoved,
|
||||
[this](const QString& convUid, const QString& interactionId) {
|
||||
void
|
||||
MessagesAdapter::onInteractionRemoved(const QString& convUid, const QString& interactionId)
|
||||
{
|
||||
Q_UNUSED(convUid);
|
||||
removeInteraction(interactionId);
|
||||
});
|
||||
}
|
||||
|
||||
newMessagesAvailableConnection_
|
||||
= QObject::connect(currentConversationModel,
|
||||
&ConversationModel::newMessagesAvailable,
|
||||
[this](const QString& accountId, const QString& conversationId) {
|
||||
auto* convModel = lrcInstance_->accountModel()
|
||||
.getAccountInfo(accountId)
|
||||
.conversationModel.get();
|
||||
void
|
||||
MessagesAdapter::onNewMessagesAvailable(const QString& accountId, const QString& conversationId)
|
||||
{
|
||||
auto* convModel = lrcInstance_->accountModel().getAccountInfo(accountId).conversationModel.get();
|
||||
auto optConv = convModel->getConversationForUid(conversationId);
|
||||
if (!optConv)
|
||||
return;
|
||||
updateHistory(*convModel,
|
||||
optConv->get().interactions,
|
||||
optConv->get().allMessagesLoaded);
|
||||
Utils::oneShotConnect(qmlObj_,
|
||||
SIGNAL(messagesLoaded()),
|
||||
this,
|
||||
SLOT(slotMessagesLoaded()));
|
||||
});
|
||||
updateHistory(*convModel, optConv->get().interactions, optConv->get().allMessagesLoaded);
|
||||
Utils::oneShotConnect(qmlObj_, SIGNAL(messagesLoaded()), this, SLOT(slotMessagesLoaded()));
|
||||
}
|
||||
|
||||
conversationUpdatedConnection_
|
||||
= QObject::connect(currentConversationModel,
|
||||
&ConversationModel::conversationReady,
|
||||
[this](const QString& conversationId) {
|
||||
void
|
||||
MessagesAdapter::updateConversation(const QString& conversationId)
|
||||
{
|
||||
if (conversationId != lrcInstance_->get_selectedConvUid())
|
||||
return;
|
||||
auto* convModel = lrcInstance_->getCurrentConversationModel();
|
||||
if (auto optConv = convModel->getConversationForUid(conversationId))
|
||||
setConversationProfileData(optConv->get());
|
||||
});
|
||||
composingConnection_
|
||||
= connect(currentConversationModel,
|
||||
&ConversationModel::composingStatusChanged,
|
||||
[this](const QString& convUid, const QString& contactUri, bool isComposing) {
|
||||
if (convUid != lrcInstance_->get_selectedConvUid())
|
||||
}
|
||||
|
||||
void
|
||||
MessagesAdapter::onComposingStatusChanged(const QString& convId,
|
||||
const QString& contactUri,
|
||||
bool isComposing)
|
||||
{
|
||||
if (convId != lrcInstance_->get_selectedConvUid())
|
||||
return;
|
||||
if (!settingsManager_->getValue(Settings::Key::EnableTypingIndicator).toBool()) {
|
||||
return;
|
||||
}
|
||||
contactIsComposing(contactUri, isComposing);
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
MessagesAdapter::connectConversationModel()
|
||||
{
|
||||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::newInteraction,
|
||||
this,
|
||||
&MessagesAdapter::onNewInteraction,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::interactionStatusUpdated,
|
||||
this,
|
||||
&MessagesAdapter::onInteractionStatusUpdated,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::interactionRemoved,
|
||||
this,
|
||||
&MessagesAdapter::onInteractionRemoved,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::newMessagesAvailable,
|
||||
this,
|
||||
&MessagesAdapter::onNewMessagesAvailable,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::conversationReady,
|
||||
this,
|
||||
&MessagesAdapter::updateConversation,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::needsSyncingSet,
|
||||
this,
|
||||
&MessagesAdapter::updateConversation,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
QObject::connect(currentConversationModel,
|
||||
&ConversationModel::composingStatusChanged,
|
||||
this,
|
||||
&MessagesAdapter::onComposingStatusChanged,
|
||||
Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -581,7 +607,8 @@ MessagesAdapter::clearChatView()
|
|||
void
|
||||
MessagesAdapter::setDisplayLinks()
|
||||
{
|
||||
QString s = QString::fromLatin1("setDisplayLinks(%1);")
|
||||
QString s
|
||||
= QString::fromLatin1("setDisplayLinks(%1);")
|
||||
.arg(settingsManager_->getValue(Settings::Key::DisplayHyperlinkPreviews).toBool());
|
||||
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ protected:
|
|||
Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& convUid);
|
||||
|
||||
// JS Q_INVOKABLE.
|
||||
Q_INVOKABLE void acceptInvitation(const QString& convUid = "");
|
||||
Q_INVOKABLE void acceptInvitation(const QString& convId = {});
|
||||
Q_INVOKABLE void refuseInvitation(const QString& convUid = "");
|
||||
Q_INVOKABLE void blockConversation(const QString& convUid = "");
|
||||
Q_INVOKABLE void setNewMessagesContent(const QString& path);
|
||||
|
@ -102,11 +102,21 @@ Q_SIGNALS:
|
|||
void contactBanned();
|
||||
void newInteraction(int type);
|
||||
|
||||
public Q_SLOTS:
|
||||
private Q_SLOTS:
|
||||
void slotSendMessageContentSaved(const QString& content);
|
||||
void slotUpdateDraft(const QString& content);
|
||||
void slotMessagesCleared();
|
||||
void slotMessagesLoaded();
|
||||
void onNewInteraction(const QString& convUid,
|
||||
const QString& interactionId,
|
||||
const interaction::Info& interaction);
|
||||
void onInteractionStatusUpdated(const QString& convUid,
|
||||
const QString& interactionId,
|
||||
const interaction::Info& interaction);
|
||||
void onInteractionRemoved(const QString& convUid, const QString& interactionId);
|
||||
void onNewMessagesAvailable(const QString& accountId, const QString& conversationId);
|
||||
void updateConversation(const QString& conversationId);
|
||||
void onComposingStatusChanged(const QString& uid, const QString& contactUri, bool isComposing);
|
||||
|
||||
private:
|
||||
void setConversationProfileData(const lrc::api::conversation::Info& convInfo);
|
||||
|
@ -120,13 +130,5 @@ private:
|
|||
|
||||
const QVariantMap chatviewTranslatedStrings_ {lrc::api::chatview::getTranslatedStrings()};
|
||||
|
||||
// Interaction connections.
|
||||
QMetaObject::Connection newInteractionConnection_;
|
||||
QMetaObject::Connection interactionStatusUpdatedConnection_;
|
||||
QMetaObject::Connection interactionRemovedConnection_;
|
||||
QMetaObject::Connection newMessagesAvailableConnection_;
|
||||
QMetaObject::Connection conversationUpdatedConnection_;
|
||||
QMetaObject::Connection composingConnection_;
|
||||
|
||||
AppSettingsManager* settingsManager_;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue