mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-04 06:03:21 +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
|
void
|
||||||
ConversationsAdapter::onConversationReady(const QString& convId)
|
ConversationsAdapter::updateConversation(const QString& convId)
|
||||||
{
|
{
|
||||||
// a conversation request has been accepted or a contact has
|
// a conversation request has been accepted or a contact has
|
||||||
// been added, so select the conversation and notify the UI to:
|
// been added, so select the conversation and notify the UI to:
|
||||||
// - switch tabs to the conversation filter tab
|
// - switch tabs to the conversation filter tab
|
||||||
// - clear search bar
|
// - clear search bar
|
||||||
lrcInstance_->selectConversation(convId);
|
|
||||||
Q_EMIT conversationReady(convId);
|
Q_EMIT conversationReady(convId);
|
||||||
|
lrcInstance_->selectConversation(convId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -426,51 +426,57 @@ ConversationsAdapter::connectConversationModel()
|
||||||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::modelChanged,
|
&ConversationModel::modelChanged,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onModelChanged,
|
&ConversationsAdapter::onModelChanged,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(lrcInstance_->getCurrentAccountInfo().contactModel.get(),
|
QObject::connect(lrcInstance_->getCurrentAccountInfo().contactModel.get(),
|
||||||
&lrc::api::ContactModel::profileUpdated,
|
&ContactModel::profileUpdated,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onProfileUpdated,
|
&ConversationsAdapter::onProfileUpdated,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::conversationUpdated,
|
&ConversationModel::conversationUpdated,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onConversationUpdated,
|
&ConversationsAdapter::onConversationUpdated,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::filterChanged,
|
&ConversationModel::filterChanged,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onFilterChanged,
|
&ConversationsAdapter::onFilterChanged,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::conversationCleared,
|
&ConversationModel::conversationCleared,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onConversationCleared,
|
&ConversationsAdapter::onConversationCleared,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::searchStatusChanged,
|
&ConversationModel::searchStatusChanged,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onSearchStatusChanged,
|
&ConversationsAdapter::onSearchStatusChanged,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::searchResultUpdated,
|
&ConversationModel::searchResultUpdated,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onSearchResultUpdated,
|
&ConversationsAdapter::onSearchResultUpdated,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
QObject::connect(currentConversationModel,
|
QObject::connect(currentConversationModel,
|
||||||
&lrc::api::ConversationModel::conversationReady,
|
&ConversationModel::conversationReady,
|
||||||
this,
|
this,
|
||||||
&ConversationsAdapter::onConversationReady,
|
&ConversationsAdapter::updateConversation,
|
||||||
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
|
QObject::connect(currentConversationModel,
|
||||||
|
&ConversationModel::needsSyncingSet,
|
||||||
|
this,
|
||||||
|
&ConversationsAdapter::updateConversation,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
convSrcModel_.reset(new ConversationListModel(lrcInstance_));
|
convSrcModel_.reset(new ConversationListModel(lrcInstance_));
|
||||||
|
|
|
@ -82,7 +82,7 @@ private Q_SLOTS:
|
||||||
void onConversationCleared(const QString&);
|
void onConversationCleared(const QString&);
|
||||||
void onSearchStatusChanged(const QString&);
|
void onSearchStatusChanged(const QString&);
|
||||||
void onSearchResultUpdated();
|
void onSearchResultUpdated();
|
||||||
void onConversationReady(const QString&);
|
void updateConversation(const QString&);
|
||||||
|
|
||||||
void updateConversationFilterData();
|
void updateConversationFilterData();
|
||||||
|
|
||||||
|
|
|
@ -118,86 +118,112 @@ MessagesAdapter::setupChatView(const QString& convUid)
|
||||||
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
|
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MessagesAdapter::onNewInteraction(const QString& convUid,
|
||||||
|
const QString& interactionId,
|
||||||
|
const lrc::api::interaction::Info& interaction)
|
||||||
|
{
|
||||||
|
auto accountId = lrcInstance_->getCurrentAccountId();
|
||||||
|
newInteraction(accountId, convUid, interactionId, interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MessagesAdapter::onInteractionStatusUpdated(const QString& convUid,
|
||||||
|
const QString& interactionId,
|
||||||
|
const lrc::api::interaction::Info& interaction)
|
||||||
|
{
|
||||||
|
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||||
|
currentConversationModel->clearUnreadInteractions(convUid);
|
||||||
|
updateInteraction(*currentConversationModel, interactionId, interaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MessagesAdapter::onInteractionRemoved(const QString& convUid, const QString& interactionId)
|
||||||
|
{
|
||||||
|
Q_UNUSED(convUid);
|
||||||
|
removeInteraction(interactionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
MessagesAdapter::connectConversationModel()
|
MessagesAdapter::connectConversationModel()
|
||||||
{
|
{
|
||||||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
||||||
|
|
||||||
QObject::disconnect(newInteractionConnection_);
|
QObject::connect(currentConversationModel,
|
||||||
QObject::disconnect(interactionRemovedConnection_);
|
&ConversationModel::newInteraction,
|
||||||
QObject::disconnect(interactionStatusUpdatedConnection_);
|
this,
|
||||||
QObject::disconnect(conversationUpdatedConnection_);
|
&MessagesAdapter::onNewInteraction,
|
||||||
QObject::disconnect(composingConnection_);
|
Qt::UniqueConnection);
|
||||||
|
|
||||||
newInteractionConnection_
|
QObject::connect(currentConversationModel,
|
||||||
= QObject::connect(currentConversationModel,
|
&ConversationModel::interactionStatusUpdated,
|
||||||
&lrc::api::ConversationModel::newInteraction,
|
this,
|
||||||
[this](const QString& convUid,
|
&MessagesAdapter::onInteractionStatusUpdated,
|
||||||
const QString& interactionId,
|
Qt::UniqueConnection);
|
||||||
const lrc::api::interaction::Info& interaction) {
|
|
||||||
auto accountId = lrcInstance_->getCurrentAccountId();
|
|
||||||
newInteraction(accountId, convUid, interactionId, interaction);
|
|
||||||
});
|
|
||||||
|
|
||||||
interactionStatusUpdatedConnection_ = QObject::connect(
|
QObject::connect(currentConversationModel,
|
||||||
currentConversationModel,
|
&ConversationModel::interactionRemoved,
|
||||||
&lrc::api::ConversationModel::interactionStatusUpdated,
|
this,
|
||||||
[this](const QString& convUid,
|
&MessagesAdapter::onInteractionRemoved,
|
||||||
const QString& interactionId,
|
Qt::UniqueConnection);
|
||||||
const lrc::api::interaction::Info& interaction) {
|
|
||||||
auto currentConversationModel = lrcInstance_->getCurrentConversationModel();
|
|
||||||
currentConversationModel->clearUnreadInteractions(convUid);
|
|
||||||
updateInteraction(*currentConversationModel, interactionId, interaction);
|
|
||||||
});
|
|
||||||
|
|
||||||
interactionRemovedConnection_
|
QObject::connect(currentConversationModel,
|
||||||
= QObject::connect(currentConversationModel,
|
&ConversationModel::newMessagesAvailable,
|
||||||
&lrc::api::ConversationModel::interactionRemoved,
|
this,
|
||||||
[this](const QString& convUid, const QString& interactionId) {
|
&MessagesAdapter::onNewMessagesAvailable,
|
||||||
Q_UNUSED(convUid);
|
Qt::UniqueConnection);
|
||||||
removeInteraction(interactionId);
|
|
||||||
});
|
|
||||||
|
|
||||||
newMessagesAvailableConnection_
|
QObject::connect(currentConversationModel,
|
||||||
= QObject::connect(currentConversationModel,
|
&ConversationModel::conversationReady,
|
||||||
&ConversationModel::newMessagesAvailable,
|
this,
|
||||||
[this](const QString& accountId, const QString& conversationId) {
|
&MessagesAdapter::updateConversation,
|
||||||
auto* convModel = lrcInstance_->accountModel()
|
Qt::UniqueConnection);
|
||||||
.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()));
|
|
||||||
});
|
|
||||||
|
|
||||||
conversationUpdatedConnection_
|
QObject::connect(currentConversationModel,
|
||||||
= QObject::connect(currentConversationModel,
|
&ConversationModel::needsSyncingSet,
|
||||||
&ConversationModel::conversationReady,
|
this,
|
||||||
[this](const QString& conversationId) {
|
&MessagesAdapter::updateConversation,
|
||||||
if (conversationId != lrcInstance_->get_selectedConvUid())
|
Qt::UniqueConnection);
|
||||||
return;
|
|
||||||
auto* convModel = lrcInstance_->getCurrentConversationModel();
|
QObject::connect(currentConversationModel,
|
||||||
if (auto optConv = convModel->getConversationForUid(conversationId))
|
&ConversationModel::composingStatusChanged,
|
||||||
setConversationProfileData(optConv->get());
|
this,
|
||||||
});
|
&MessagesAdapter::onComposingStatusChanged,
|
||||||
composingConnection_
|
Qt::UniqueConnection);
|
||||||
= connect(currentConversationModel,
|
|
||||||
&ConversationModel::composingStatusChanged,
|
|
||||||
[this](const QString& convUid, const QString& contactUri, bool isComposing) {
|
|
||||||
if (convUid != lrcInstance_->get_selectedConvUid())
|
|
||||||
return;
|
|
||||||
if (!settingsManager_->getValue(Settings::Key::EnableTypingIndicator).toBool()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
contactIsComposing(contactUri, isComposing);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -581,8 +607,9 @@ MessagesAdapter::clearChatView()
|
||||||
void
|
void
|
||||||
MessagesAdapter::setDisplayLinks()
|
MessagesAdapter::setDisplayLinks()
|
||||||
{
|
{
|
||||||
QString s = QString::fromLatin1("setDisplayLinks(%1);")
|
QString s
|
||||||
.arg(settingsManager_->getValue(Settings::Key::DisplayHyperlinkPreviews).toBool());
|
= QString::fromLatin1("setDisplayLinks(%1);")
|
||||||
|
.arg(settingsManager_->getValue(Settings::Key::DisplayHyperlinkPreviews).toBool());
|
||||||
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
|
QMetaObject::invokeMethod(qmlObj_, "webViewRunJavaScript", Q_ARG(QVariant, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ protected:
|
||||||
Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& convUid);
|
Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& convUid);
|
||||||
|
|
||||||
// JS Q_INVOKABLE.
|
// 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 refuseInvitation(const QString& convUid = "");
|
||||||
Q_INVOKABLE void blockConversation(const QString& convUid = "");
|
Q_INVOKABLE void blockConversation(const QString& convUid = "");
|
||||||
Q_INVOKABLE void setNewMessagesContent(const QString& path);
|
Q_INVOKABLE void setNewMessagesContent(const QString& path);
|
||||||
|
@ -102,11 +102,21 @@ Q_SIGNALS:
|
||||||
void contactBanned();
|
void contactBanned();
|
||||||
void newInteraction(int type);
|
void newInteraction(int type);
|
||||||
|
|
||||||
public Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotSendMessageContentSaved(const QString& content);
|
void slotSendMessageContentSaved(const QString& content);
|
||||||
void slotUpdateDraft(const QString& content);
|
void slotUpdateDraft(const QString& content);
|
||||||
void slotMessagesCleared();
|
void slotMessagesCleared();
|
||||||
void slotMessagesLoaded();
|
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:
|
private:
|
||||||
void setConversationProfileData(const lrc::api::conversation::Info& convInfo);
|
void setConversationProfileData(const lrc::api::conversation::Info& convInfo);
|
||||||
|
@ -120,13 +130,5 @@ private:
|
||||||
|
|
||||||
const QVariantMap chatviewTranslatedStrings_ {lrc::api::chatview::getTranslatedStrings()};
|
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_;
|
AppSettingsManager* settingsManager_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue