1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-04-21 21:52:03 +02:00

conversations: support new APIs for user search

Gitlab: #4
Change-Id: I7570099c20d2d406e538aea4c366ba7d85777686
This commit is contained in:
ababi 2020-08-18 17:21:28 +02:00
parent 449eda362a
commit 0b68664220
18 changed files with 378 additions and 265 deletions

View file

@ -386,7 +386,9 @@ AccountAdapter::connectAccount(const QString &accountId)
[this, accountId](const QString &contactUri) {
auto &accInfo = LRCInstance::accountModel().getAccountInfo(
accountId);
auto conversation = LRCInstance::getCurrentConversation();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(
LRCInstance::getCurrentConvUid());
if (conversation.uid.isEmpty()) {
return;
}

View file

@ -37,7 +37,8 @@ AvAdapter::initQmlObject()
QVariantMap
AvAdapter::populateVideoDeviceContextMenuItem()
{
auto conversation = LRCInstance::getCurrentConversation();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
auto call = LRCInstance::getCallInfoForConversation(conversation);
if (!call) {
return QVariantMap();

View file

@ -62,25 +62,26 @@ CallAdapter::slotAccountChanged()
void
CallAdapter::placeAudioOnlyCall()
{
auto convInfo = LRCInstance::getCurrentConversation();
if (!convInfo.uid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->placeAudioOnlyCall(convInfo.uid);
const auto convUid = LRCInstance::getCurrentConvUid();
if (!convUid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->placeAudioOnlyCall(convUid);
}
}
void
CallAdapter::placeCall()
{
auto convInfo = LRCInstance::getCurrentConversation();
if (!convInfo.uid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->placeCall(convInfo.uid);
const auto convUid = LRCInstance::getCurrentConvUid();
if (!convUid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->placeCall(convUid);
}
}
void
CallAdapter::hangUpACall(const QString &accountId, const QString &convUid)
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) {
LRCInstance::getAccountInfo(accountId).callModel->hangUp(convInfo.callId);
}
@ -89,7 +90,8 @@ CallAdapter::hangUpACall(const QString &accountId, const QString &convUid)
void
CallAdapter::refuseACall(const QString &accountId, const QString &convUid)
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) {
LRCInstance::getAccountInfo(accountId).callModel->refuse(convInfo.callId);
}
@ -99,7 +101,8 @@ void
CallAdapter::acceptACall(const QString &accountId, const QString &convUid)
{
emit incomingCallNeedToSetupMainView(accountId, convUid);
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) {
LRCInstance::getAccountInfo(accountId).callModel->accept(convInfo.callId);
auto &accInfo = LRCInstance::getAccountInfo(convInfo.accountId);
@ -110,7 +113,7 @@ CallAdapter::acceptACall(const QString &accountId, const QString &convUid)
void
CallAdapter::slotShowIncomingCallView(const QString &accountId, const conversation::Info &convInfo)
{
auto callModel = LRCInstance::getCurrentCallModel();
auto* callModel = LRCInstance::getCurrentCallModel();
if (!callModel->hasCall(convInfo.callId)) {
/*
@ -190,7 +193,8 @@ CallAdapter::updateCall(const QString &convUid, const QString &accountId, bool f
accountId_ = accountId.isEmpty() ? accountId_ : accountId;
convUid_ = convUid.isEmpty() ? convUid_ : convUid;
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto *convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (convInfo.uid.isEmpty()) {
return;
}
@ -220,7 +224,8 @@ bool
CallAdapter::shouldShowPreview(bool force)
{
bool shouldShowPreview{false};
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (convInfo.uid.isEmpty()) {
return shouldShowPreview;
}
@ -236,7 +241,8 @@ QVariantList
CallAdapter::getConferencesInfos()
{
QVariantList map;
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (convInfo.uid.isEmpty())
return map;
auto callId = convInfo.confId.isEmpty()? convInfo.callId : convInfo.confId;
@ -287,7 +293,7 @@ CallAdapter::connectCallModel(const QString &accountId)
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
auto &callModel = accInfo.callModel;
auto call = callModel->getCall(confId);
auto convInfo = LRCInstance::getConversationFromCallId(confId);
const auto convInfo = LRCInstance::getConversationFromCallId(confId);
if (!convInfo.uid.isEmpty()) {
// Convert to QML
QVariantList map;
@ -324,12 +330,12 @@ CallAdapter::connectCallModel(const QString &accountId)
[this, accountId](const QString &callId) {
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
auto &callModel = accInfo.callModel;
auto call = callModel->getCall(callId);
const auto call = callModel->getCall(callId);
/*
* Change status label text.
*/
auto convInfo = LRCInstance::getConversationFromCallId(callId);
const auto convInfo = LRCInstance::getConversationFromCallId(callId);
if (!convInfo.uid.isEmpty()) {
emit callStatusChanged(lrc::api::call::to_string(call.status),
accountId,
@ -383,7 +389,7 @@ CallAdapter::connectCallModel(const QString &accountId)
}
case lrc::api::call::Status::CONNECTED:
case lrc::api::call::Status::IN_PROGRESS: {
auto convInfo = LRCInstance::getConversationFromCallId(callId, accountId);
const auto convInfo = LRCInstance::getConversationFromCallId(callId, accountId);
if (!convInfo.uid.isEmpty() && convInfo.uid == LRCInstance::getCurrentConvUid()) {
accInfo.conversationModel->selectConversation(convInfo.uid);
}
@ -439,7 +445,7 @@ CallAdapter::updateCallOverlay(const lrc::api::conversation::Info &convInfo)
void
CallAdapter::hangupCall(const QString& uri)
{
auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_);
const auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_);
if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
if (callModel->hasCall(convInfo.callId)) {
@ -466,17 +472,20 @@ CallAdapter::hangupCall(const QString& uri)
void
CallAdapter::maximizeParticipant(const QString& uri, bool isActive)
{
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto confId = LRCInstance::getCurrentConversation().confId;
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
const auto confId = conversation.confId;
QString callId;
if (LRCInstance::getCurrentAccountInfo().profileInfo.uri != uri) {
auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_);
const auto convInfo = LRCInstance::getConversationFromPeerUri(uri, accountId_);
if (!convInfo.uid.isEmpty()) {
callId = convInfo.callId;
}
}
try {
auto call = callModel->getCall(confId);
const auto call = callModel->getCall(confId);
switch (call.layout) {
case lrc::api::call::Layout::GRID:
callModel->setActiveParticipant(confId, callId);
@ -498,8 +507,10 @@ CallAdapter::maximizeParticipant(const QString& uri, bool isActive)
void
CallAdapter::minimizeParticipant()
{
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto confId = LRCInstance::getCurrentConversation().confId;
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
const auto confId = conversation.confId;
try {
auto call = callModel->getCall(confId);
switch (call.layout) {
@ -518,9 +529,10 @@ CallAdapter::minimizeParticipant()
void
CallAdapter::hangUpThisCall()
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) {
callModel->hangUp(convInfo.confId);
} else if (callModel->hasCall(convInfo.callId)) {
@ -533,7 +545,8 @@ bool
CallAdapter::isRecordingThisCall()
{
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId_);
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto &convModel = accInfo.conversationModel;
const auto convInfo = convModel->getConversationForUID(convUid_);
return accInfo.callModel->isRecording(convInfo.confId)
|| accInfo.callModel->isRecording(convInfo.callId);
}
@ -541,9 +554,10 @@ CallAdapter::isRecordingThisCall()
bool
CallAdapter::isCurrentMaster() const
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
try {
if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) {
return true;
@ -559,9 +573,10 @@ CallAdapter::isCurrentMaster() const
int
CallAdapter::getCurrentLayoutType() const
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
try {
auto call = callModel->getCall(convInfo.confId);
return Utils::toUnderlyingValue(call.layout);
@ -573,11 +588,11 @@ CallAdapter::getCurrentLayoutType() const
void
CallAdapter::holdThisCallToggle()
{
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return;
}
auto callModel = LRCInstance::getCurrentCallModel();
auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) {
callModel->togglePause(callId);
}
@ -587,11 +602,11 @@ CallAdapter::holdThisCallToggle()
void
CallAdapter::muteThisCallToggle()
{
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return;
}
auto callModel = LRCInstance::getCurrentCallModel();
auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) {
callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO);
}
@ -600,11 +615,11 @@ CallAdapter::muteThisCallToggle()
void
CallAdapter::recordThisCallToggle()
{
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return;
}
auto callModel = LRCInstance::getCurrentCallModel();
auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) {
callModel->toggleAudioRecord(callId);
}
@ -613,11 +628,11 @@ CallAdapter::recordThisCallToggle()
void
CallAdapter::videoPauseThisCallToggle()
{
auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
const auto callId = LRCInstance::getCallIdForConversationUid(convUid_, accountId_);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return;
}
auto callModel = LRCInstance::getCurrentCallModel();
auto* callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(callId)) {
callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO);
}
@ -627,11 +642,11 @@ CallAdapter::videoPauseThisCallToggle()
void
CallAdapter::setTime(const QString &accountId, const QString &convUid)
{
auto callId = LRCInstance::getCallIdForConversationUid(convUid, accountId);
const auto callId = LRCInstance::getCallIdForConversationUid(convUid, accountId);
if (callId.isEmpty() || !LRCInstance::getCurrentCallModel()->hasCall(callId)) {
return;
}
auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId);
const auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId);
if (callInfo.status == lrc::api::call::Status::IN_PROGRESS
|| callInfo.status == lrc::api::call::Status::PAUSED) {
auto timeString = LRCInstance::getCurrentCallModel()->getFormattedCallDuration(callId);

View file

@ -91,8 +91,9 @@ void
ContactAdapter::contactSelected(int index)
{
auto contactIndex = selectableProxyModel_->index(index, 0);
auto callModel = LRCInstance::getCurrentCallModel();
auto conversation = LRCInstance::getCurrentConversation();
auto* callModel = LRCInstance::getCurrentCallModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
if (contactIndex.isValid()) {
switch (listModeltype_) {
@ -100,15 +101,15 @@ ContactAdapter::contactSelected(int index)
/*
* Conference.
*/
auto sectionName = contactIndex.data(SmartListModel::Role::SectionName).value<QString>();
const auto sectionName = contactIndex.data(SmartListModel::Role::SectionName).value<QString>();
if (!sectionName.isEmpty()) {
smartListModel_->toggleSection(sectionName);
return;
}
auto convUid = contactIndex.data(SmartListModel::Role::UID).value<QString>();
auto accId = contactIndex.data(SmartListModel::Role::AccountId).value<QString>();
auto callId = LRCInstance::getCallIdForConversationUid(convUid, accId);
const auto convUid = contactIndex.data(SmartListModel::Role::UID).value<QString>();
const auto accId = contactIndex.data(SmartListModel::Role::AccountId).value<QString>();
const auto callId = LRCInstance::getCallIdForConversationUid(convUid, accId);
if (!callId.isEmpty()) {
if (conversation.uid.isEmpty()) {
@ -119,7 +120,7 @@ ContactAdapter::contactSelected(int index)
callModel->joinCalls(thisCallId, callId);
} else {
auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>();
const auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>();
auto call = LRCInstance::getCallInfoForConversation(conversation);
if (!call) {
return;
@ -131,12 +132,12 @@ ContactAdapter::contactSelected(int index)
/*
* SIP Transfer.
*/
auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>();
const auto contactUri = contactIndex.data(SmartListModel::Role::URI).value<QString>();
if (conversation.uid.isEmpty()) {
return;
}
auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
const auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
QString destCallId;
@ -144,7 +145,7 @@ ContactAdapter::contactSelected(int index)
/*
* Check if the call exist - (check non-finished calls).
*/
auto callInfo = callModel->getCallFromURI(contactUri, true);
const auto callInfo = callModel->getCallFromURI(contactUri, true);
destCallId = callInfo.id;
} catch (std::exception &e) {
qDebug().noquote() << e.what();

View file

@ -36,8 +36,7 @@ ConversationsAdapter::initQmlObject()
{
conversationSmartListModel_ = new SmartListModel(LRCInstance::getCurrAccId(), this);
QMetaObject::invokeMethod(qmlObj_,
"setModel",
QMetaObject::invokeMethod(qmlObj_, "setModel",
Q_ARG(QVariant, QVariant::fromValue(conversationSmartListModel_)));
connect(&LRCInstance::behaviorController(),
@ -71,30 +70,25 @@ ConversationsAdapter::selectConversation(const QString &accountId,
const QString &convUid,
bool preventSendingSignal)
{
selectConversation(LRCInstance::getConversationFromConvUid(convUid, accountId),
preventSendingSignal);
auto &accInfo = LRCInstance::getAccountInfo(accountId);
const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
selectConversation(convInfo, preventSendingSignal);
}
void
ConversationsAdapter::selectConversation(int index)
ConversationsAdapter::selectConversation(const QString &convUid)
{
auto convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) {
return;
}
const auto item = convModel->filteredConversation(index);
const auto &conversation = convModel->getConversationForUID(convUid);
if (selectConversation(item, false)) {
auto convUid = conversationSmartListModel_
->data(conversationSmartListModel_->index(index, 0),
static_cast<int>(SmartListModel::Role::UID))
.toString();
auto &conversation = LRCInstance::getConversationFromConvUid(convUid);
/*
* If it is calling, show callview (can use showChatView signal, since it will be determined on qml).
*/
if (selectConversation(conversation, false)) {
// If it is calling, show callview (can use showChatView signal, since it will be determined on qml).
if (!conversation.uid.isEmpty()
&& LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) {
emit showChatView(LRCInstance::getCurrAccId(), conversation.uid);
@ -106,11 +100,9 @@ bool
ConversationsAdapter::selectConversation(const lrc::api::conversation::Info &item,
bool preventSendingSignal)
{
/*
* accInfo.conversationModel->selectConversation(item.uid) only emit ui
* behavior control signals, but sometimes we do not want that,
* preventSendingSignal boolean can help us to determine.
*/
// accInfo.conversationModel->selectConversation(item.uid) only emit ui
// behavior control signals, but sometimes we do not want that,
// preventSendingSignal boolean can help us to determine.
if (LRCInstance::getCurrentConvUid() == item.uid) {
return false;
} else if (item.participants.size() > 0) {
@ -143,9 +135,7 @@ ConversationsAdapter::deselectConversation()
void
ConversationsAdapter::accountChangedSetUp(const QString &accountId)
{
/*
* Should be called when current account is changed.
*/
// Should be called when current account is changed.
auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId);
currentTypeFilter_ = accountInfo.profileInfo.type;
LRCInstance::getCurrentConversationModel()->setFilter(accountInfo.profileInfo.type);
@ -157,9 +147,7 @@ ConversationsAdapter::accountChangedSetUp(const QString &accountId)
void
ConversationsAdapter::updateConversationsFilterWidget()
{
/*
* Update status of "Conversations" and "Invitations".
*/
// Update status of "Conversations" and "Invitations".
auto invites = LRCInstance::getCurrentAccountInfo().contactModel->pendingRequestCount();
if (invites == 0 && currentTypeFilter_ == lrc::api::profile::Type::PENDING) {
currentTypeFilter_ = lrc::api::profile::Type::RING;
@ -171,10 +159,8 @@ ConversationsAdapter::updateConversationsFilterWidget()
void
ConversationsAdapter::setConversationFilter(const QString &type)
{
/*
* Set conversation filter according to type,
* type needs to be recognizable by lrc::api::profile::to_type.
*/
// Set conversation filter according to type,
// type needs to be recognizable by lrc::api::profile::to_type.
if (type.isEmpty()) {
if (LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::RING)
setConversationFilter(lrc::api::profile::Type::RING);
@ -198,10 +184,8 @@ ConversationsAdapter::setConversationFilter(lrc::api::profile::Type filter)
bool
ConversationsAdapter::connectConversationModel()
{
/*
* Signal connections
*/
auto currentConversationModel = LRCInstance::getCurrentAccountInfo().conversationModel.get();
// Signal connections
auto currentConversationModel = LRCInstance::getCurrentConversationModel();
QObject::disconnect(modelSortedConnection_);
QObject::disconnect(modelUpdatedConnection_);
@ -211,18 +195,22 @@ ConversationsAdapter::connectConversationModel()
QObject::disconnect(conversationClearedConnection);
QObject::disconnect(newInteractionConnection_);
QObject::disconnect(interactionRemovedConnection_);
QObject::disconnect(searchStatusChangedConnection_);
QObject::disconnect(searchResultUpdatedConnection_);
modelSortedConnection_ = QObject::connect(
currentConversationModel, &lrc::api::ConversationModel::modelSorted, [this]() {
modelSortedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::modelSorted,
[this]() {
conversationSmartListModel_->fillConversationsList();
updateConversationsFilterWidget();
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
auto convUid = LRCInstance::getCurrentConversation().uid;
auto convModel = LRCInstance::getCurrentConversationModel();
auto &conversation = LRCInstance::getConversationFromConvUid(convUid);
if (conversation.uid.isEmpty()) {
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
if (conversation.uid.isEmpty() || conversation.participants.isEmpty()) {
return;
}
auto contactURI = conversation.participants[0];
const auto contactURI = conversation.participants[0];
if (contactURI.isEmpty()
|| convModel->owner.contactModel->getContact(contactURI).profileInfo.type
== lrc::api::profile::Type::TEMPORARY) {
@ -231,17 +219,18 @@ ConversationsAdapter::connectConversationModel()
QMetaObject::invokeMethod(qmlObj_, "modelSorted", Q_ARG(QVariant, contactURI));
});
modelUpdatedConnection_
= QObject::connect(currentConversationModel,
modelUpdatedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::conversationUpdated,
[this](const QString &convUid) {
Q_UNUSED(convUid);
conversationSmartListModel_->updateConversation(convUid);
updateConversationsFilterWidget();
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
filterChangedConnection_ = QObject::connect(
currentConversationModel, &lrc::api::ConversationModel::filterChanged, [this]() {
filterChangedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::filterChanged,
[this]() {
conversationSmartListModel_->fillConversationsList();
QMetaObject::invokeMethod(qmlObj_,
"updateSmartList",
Q_ARG(QVariant, LRCInstance::getCurrAccId()));
@ -249,44 +238,56 @@ ConversationsAdapter::connectConversationModel()
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
newConversationConnection_
= QObject::connect(currentConversationModel,
newConversationConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::newConversation,
[this](const QString &convUid) {
conversationSmartListModel_->fillConversationsList();
QMetaObject::invokeMethod(qmlObj_,
"updateSmartList",
Q_ARG(QVariant,
LRCInstance::getCurrAccId()));
Q_ARG(QVariant, LRCInstance::getCurrAccId()));
updateConversationForNewContact(convUid);
});
conversationRemovedConnection_
= QObject::connect(currentConversationModel,
conversationRemovedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::conversationRemoved,
[this]() { backToWelcomePage(); });
[this]() {
conversationSmartListModel_->fillConversationsList();
backToWelcomePage();
});
conversationClearedConnection
= QObject::connect(currentConversationModel,
conversationClearedConnection = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::conversationCleared,
[this](const QString &convUid) {
/*
* If currently selected,
* switch to welcome screen (deselecting current smartlist item ).
*/
// If currently selected, switch to welcome screen (deselecting current smartlist item ).
if (convUid != LRCInstance::getCurrentConvUid()) {
return;
}
backToWelcomePage();
});
newInteractionConnection_
= QObject::connect(currentConversationModel,
newInteractionConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::newInteraction,
[this] {
conversationSmartListModel_->fillConversationsList();
updateConversationsFilterWidget();
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
searchStatusChangedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchStatusChanged,
[this](const QString &status) {
emit showSearchStatus(status);
});
searchResultUpdatedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchResultUpdated,
[this]() {
conversationSmartListModel_->fillConversationsList();
QMetaObject::invokeMethod(qmlObj_, "updateSmartList",
Q_ARG(QVariant, LRCInstance::getCurrAccId()));
QMetaObject::invokeMethod(qmlObj_, "updateConversationSmartListView");
});
currentConversationModel->setFilter("");
return true;
}
@ -294,15 +295,15 @@ ConversationsAdapter::connectConversationModel()
void
ConversationsAdapter::updateConversationForNewContact(const QString &convUid)
{
auto convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) {
return;
}
auto selectedUid = LRCInstance::getCurrentConvUid();
auto &conversation = LRCInstance::getConversationFromConvUid(convUid, {}, true);
if (!conversation.uid.isEmpty()) {
const auto selectedUid = LRCInstance::getCurrentConvUid();
const auto conversation = convModel->getConversationForUID(convUid);
if (!conversation.uid.isEmpty() && !conversation.participants.isEmpty()) {
try {
auto contact = convModel->owner.contactModel->getContact(conversation.participants[0]);
const auto contact = convModel->owner.contactModel->getContact(conversation.participants[0]);
if (!contact.profileInfo.uri.isEmpty() && contact.profileInfo.uri == selectedUid) {
LRCInstance::setSelectedConvId(convUid);
convModel->selectConversation(convUid);

View file

@ -37,7 +37,7 @@ public:
Q_INVOKABLE void selectConversation(const QString &accountId,
const QString &convUid,
bool preventSendingSignal = true);
Q_INVOKABLE void selectConversation(int index);
Q_INVOKABLE void selectConversation(const QString &uid);
Q_INVOKABLE void deselectConversation();
Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationsFilterWidget();
@ -46,6 +46,7 @@ public:
signals:
void showChatView(const QString &accountId, const QString &convUid);
void showConversationTabs(bool visible);
void showSearchStatus(const QString &status);
public slots:
void slotAccountChanged();
@ -75,4 +76,6 @@ private:
QMetaObject::Connection selectedCallChanged_;
QMetaObject::Connection smartlistSelectionConnection_;
QMetaObject::Connection interactionRemovedConnection_;
QMetaObject::Connection searchStatusChangedConnection_;
QMetaObject::Connection searchResultUpdatedConnection_;
};

View file

@ -156,7 +156,8 @@ public:
static QString
getCallIdForConversationUid(const QString &convUid, const QString &accountId)
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto &accInfo = LRCInstance::getAccountInfo(accountId);
auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
if (convInfo.uid.isEmpty()) {
return {};
}
@ -233,16 +234,6 @@ public:
filtered);
}
static const conversation::Info &
getConversationFromConvUid(const QString &convUid,
const QString &accountId = {},
bool filtered = false)
{
return getConversation(
!accountId.isEmpty() ? accountId : getCurrAccId(),
[&](const conversation::Info &conv) -> bool { return convUid == conv.uid; },
filtered);
}
static const conversation::Info &
getConversationFromPeerUri(const QString &peerUri,
const QString &accountId = {},
bool filtered = false)
@ -252,11 +243,6 @@ public:
[&](const conversation::Info &conv) -> bool { return peerUri == conv.participants[0]; },
filtered);
}
static const conversation::Info &
getCurrentConversation()
{
return getConversationFromConvUid(getCurrentConvUid());
}
static ConversationModel *
getCurrentConversationModel()

View file

@ -25,7 +25,7 @@ ListView {
id: conversationSmartListView
signal needToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr)
signal needToSelectItems(int index)
signal needToSelectItems(string conversationUid)
signal needToDeselectItems
signal needToBackToWelcomePage
signal needToGrabFocus

View file

@ -84,13 +84,15 @@ ItemDelegate {
anchors.left: conversationSmartListUserImage.right
anchors.leftMargin: 16
anchors.top: parent.top
anchors.topMargin: 16
anchors.topMargin: conversationSmartListUserLastInteractionMessage.text !== "" ?
16 : parent.height/2-conversationSmartListUserName.height/2
anchors.right: parent.right
anchors.rightMargin: 10
Text {
id: conversationSmartListUserName
Layout.alignment: Qt.AlignLeft
Layout.alignment: conversationSmartListUserLastInteractionMessage.text !== "" ?
Qt.AlignLeft : Qt.AlignLeft | Qt.AlignVCenter
TextMetrics {
id: textMetricsConversationSmartListUserName
@ -197,7 +199,7 @@ ItemDelegate {
smartListContextMenu.openMenu()
} else if (mouse.button === Qt.LeftButton) {
conversationSmartListView.currentIndex = index
conversationSmartListView.needToSelectItems(index)
conversationSmartListView.needToSelectItems(UID)
conversationSmartListView.needToGrabFocus()
}
}

View file

@ -98,7 +98,7 @@ Rectangle {
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
Layout.preferredWidth: userNameOrIdRect.width
Layout.preferredHeight: textMetricsuserAliasLabel.boundingRect.height
Layout.topMargin: userUserNameLabel.text == "" ? 0 : 10
Layout.topMargin: userUserNameLabel.text === "" ? 0 : 10
font.pointSize: JamiTheme.menuFontSize
@ -119,7 +119,7 @@ Rectangle {
Label {
id: userUserNameLabel
visible: (text != "")
visible: (text !== "")
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
Layout.preferredWidth: userNameOrIdRect.width
Layout.preferredHeight: textMetricsuserUserNameLabel.boundingRect.height

View file

@ -136,13 +136,13 @@ Rectangle {
}
function stopRecording() {
if (pathRecorder != "") {
if (pathRecorder !== "") {
ClientWrapper.avmodel.stopLocalRecorder(pathRecorder)
}
}
function sendRecord() {
if (pathRecorder != "") {
if (pathRecorder !== "") {
MessagesAdapter.sendFile(pathRecorder)
}
}

View file

@ -152,12 +152,68 @@ Rectangle {
height: tabBarVisible ? 64 : 0
}
Rectangle {
id: searchStatusRect
visible: lblSearchStatus.text !== ""
anchors.top: tabBarVisible ? sidePanelTabBar.bottom : contactSearchBar.bottom
anchors.topMargin: tabBarVisible ? 0 : 10
width: parent.width
height: 72
color: "transparent"
Image {
id: searchIcon
anchors.left: searchStatusRect.left
anchors.leftMargin: 24
anchors.verticalCenter: searchStatusRect.verticalCenter
width: 24
height: 24
fillMode: Image.PreserveAspectFit
mipmap: true
source: "qrc:/images/icons/ic_baseline-search-24px.svg"
}
Label {
id: lblSearchStatus
anchors.verticalCenter: searchStatusRect.verticalCenter
anchors.left: searchIcon.right
anchors.leftMargin: 24
width: searchStatusRect.width - searchIcon.width - 24*2 - 8
text: ""
wrapMode: Text.WordWrap
font.pointSize: JamiTheme.menuFontSize
}
MouseArea {
id: mouseAreaSearchRect
anchors.fill: parent
hoverEnabled: true
onReleased: {
searchStatusRect.color = JamiTheme.releaseColor
}
onEntered: {
searchStatusRect.color = JamiTheme.hoverColor
}
onExited: {
searchStatusRect.color = JamiTheme.backgroundColor
}
}
}
ConversationSmartListView {
id: conversationSmartListView
anchors.top: tabBarVisible ? sidePanelTabBar.bottom : contactSearchBar.bottom
anchors.topMargin: tabBarVisible ? 0 : 10
anchors.top: searchStatusRect.visible ? searchStatusRect.bottom : (tabBarVisible ? sidePanelTabBar.bottom : contactSearchBar.bottom)
anchors.topMargin: (tabBarVisible || searchStatusRect.visible) ? 0 : 10
width: parent.width
height: tabBarVisible ? sidePanelRect.height - sidePanelTabBar.height - contactSearchBar.height - 20 :
sidePanelRect.height - contactSearchBar.height - 20
@ -175,10 +231,14 @@ Rectangle {
updatePendingRequestCount()
updateTotalUnreadMessagesCount()
}
function onShowSearchStatus(status) {
lblSearchStatus.text = status
}
}
onNeedToSelectItems: {
ConversationsAdapter.selectConversation(index)
ConversationsAdapter.selectConversation(conversationUid)
}
onNeedToBackToWelcomePage: {

View file

@ -57,8 +57,13 @@ MessagesAdapter::slotAccountChanged()
void
MessagesAdapter::setupChatView(const QString &uid)
{
auto &convInfo = LRCInstance::getConversationFromConvUid(uid);
if (convInfo.uid.isEmpty()) {
auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) {
return;
}
const auto &convInfo = convModel->getConversationForUID(uid);
if (convInfo.uid.isEmpty() || convInfo.participants.isEmpty()) {
return;
}
@ -111,33 +116,25 @@ MessagesAdapter::setupChatView(const QString &uid)
void
MessagesAdapter::connectConversationModel()
{
auto currentConversationModel = LRCInstance::getCurrentAccountInfo().conversationModel.get();
auto currentConversationModel = LRCInstance::getCurrentConversationModel();
QObject::disconnect(newInteractionConnection_);
QObject::disconnect(interactionRemovedConnection_);
QObject::disconnect(interactionStatusUpdatedConnection_);
newInteractionConnection_
= QObject::connect(currentConversationModel,
newInteractionConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::newInteraction,
[this](const QString &convUid,
uint64_t interactionId,
[this](const QString &convUid, uint64_t interactionId,
const lrc::api::interaction::Info &interaction) {
auto accountId = LRCInstance::getCurrAccId();
newInteraction(accountId, convUid, interactionId, interaction);
});
interactionStatusUpdatedConnection_ = QObject::connect(
currentConversationModel,
interactionStatusUpdatedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::interactionStatusUpdated,
[this](const QString &convUid,
uint64_t interactionId,
[this](const QString &convUid, uint64_t interactionId,
const lrc::api::interaction::Info &interaction) {
if (convUid != LRCInstance::getCurrentConvUid()) {
return;
}
auto &currentAccountInfo = LRCInstance::getCurrentAccountInfo();
auto currentConversationModel = currentAccountInfo.conversationModel.get();
auto currentConversationModel = LRCInstance::getCurrentConversationModel();
currentConversationModel->clearUnreadInteractions(convUid);
updateInteraction(*currentConversationModel, interactionId, interaction);
});
@ -156,16 +153,16 @@ MessagesAdapter::connectConversationModel()
void
MessagesAdapter::sendContactRequest()
{
auto convInfo = LRCInstance::getCurrentConversation();
if (!convInfo.uid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->makePermanent(convInfo.uid);
const auto convUid = LRCInstance::getCurrentConvUid();
if (!convUid.isEmpty()) {
LRCInstance::getCurrentConversationModel()->makePermanent(convUid);
}
}
void
MessagesAdapter::accountChangedSetUp(const QString &accoountId)
MessagesAdapter::accountChangedSetUp(const QString &accountId)
{
Q_UNUSED(accoountId)
Q_UNUSED(accountId)
connectConversationModel();
}
@ -173,8 +170,8 @@ MessagesAdapter::accountChangedSetUp(const QString &accoountId)
void
MessagesAdapter::updateConversationForAddedContact()
{
auto conversation = LRCInstance::getCurrentConversation();
auto convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
clear();
setConversationProfileData(conversation);
@ -211,8 +208,8 @@ MessagesAdapter::slotUpdateDraft(const QString &content)
void
MessagesAdapter::slotMessagesCleared()
{
auto &convInfo = LRCInstance::getConversationFromConvUid(LRCInstance::getCurrentConvUid());
auto convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
printHistory(*convModel, convInfo.interactions);
@ -231,7 +228,7 @@ void
MessagesAdapter::sendMessage(const QString &message)
{
try {
auto convUid = LRCInstance::getCurrentConvUid();
const auto convUid = LRCInstance::getCurrentConvUid();
LRCInstance::getCurrentConversationModel()->sendMessage(convUid, message);
} catch (...) {
qDebug() << "Exception during sendMessage:" << message;
@ -373,7 +370,7 @@ MessagesAdapter::refuseFile(const QString &arg)
{
try {
auto interactionUid = arg.toLongLong();
auto convUid = LRCInstance::getCurrentConvUid();
const auto convUid = LRCInstance::getCurrentConvUid();
LRCInstance::getCurrentConversationModel()->cancelTransfer(convUid, interactionUid);
} catch (...) {
qDebug() << "JS bridging - exception during refuseFile:" << arg;
@ -436,10 +433,15 @@ MessagesAdapter::onComposing(bool isComposing)
void
MessagesAdapter::setConversationProfileData(const lrc::api::conversation::Info &convInfo)
{
auto convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
auto accInfo = &LRCInstance::getCurrentAccountInfo();
auto contactUri = convInfo.participants.front();
const auto conv = convModel->getConversationForUID(convInfo.uid);
if (conv.participants.isEmpty()) {
return;
}
auto contactUri = conv.participants.front();
if (contactUri.isEmpty()) {
return;
}
@ -473,7 +475,7 @@ MessagesAdapter::newInteraction(const QString &accountId,
try {
auto &accountInfo = LRCInstance::getAccountInfo(accountId);
auto &convModel = accountInfo.conversationModel;
auto &conversation = LRCInstance::getConversationFromConvUid(convUid, accountId);
const auto conversation = convModel->getConversationForUID(convUid);
if (conversation.uid.isEmpty()) {
return;
@ -646,7 +648,7 @@ MessagesAdapter::contactIsComposing(const QString &uid, const QString &contactUr
void
MessagesAdapter::acceptInvitation()
{
auto convUid = LRCInstance::getCurrentConvUid();
const auto convUid = LRCInstance::getCurrentConvUid();
LRCInstance::getCurrentConversationModel()->makePermanent(convUid);
}

View file

@ -35,7 +35,7 @@ public:
Q_INVOKABLE void setupChatView(const QString &uid);
Q_INVOKABLE void connectConversationModel();
Q_INVOKABLE void sendContactRequest();
Q_INVOKABLE void accountChangedSetUp(const QString &accoountId);
Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationForAddedContact();
/*

View file

@ -53,7 +53,9 @@ public:
/*
* For contact_xxx, xxx is "" initially
*/
auto convInfo = LRCInstance::getConversationFromConvUid(list[1]);
auto convModel = LRCInstance::getCurrentConversationModel();
auto convInfo = convModel->getConversationForUID(list[1]);
auto contact = LRCInstance::getCurrentAccountInfo().contactModel->getContact(
convInfo.participants.at(0));
return QPair(QrType::Contact, contact.profileInfo.uri);

View file

@ -65,7 +65,8 @@ SmartListModel::rowCount(const QModelIndex &parent) const
}
return rowCount;
}
return accInfo.conversationModel->allFilteredConversations().size();
return accInfo.conversationModel->allFilteredConversations().size()
+ accInfo.conversationModel->getAllSearchResults().size();
}
return 0;
}
@ -130,11 +131,11 @@ SmartListModel::data(const QModelIndex &index, int role) const
if (role == Role::AccountId) {
return QVariant(itemAccId);
}
item = LRCInstance::getConversationFromConvUid(itemConvUid, itemAccId);
auto &itemAccountInfo = LRCInstance::accountModel().getAccountInfo(itemAccId);
item = itemAccountInfo.conversationModel->getConversationForUID(itemConvUid);
return getConversationItemData(item, itemAccountInfo, role);
} else if (listModelType_ == Type::CONVERSATION) {
item = convModel->filteredConversation(index.row());
item = conversations_.at(index.row());
return getConversationItemData(item, accountInfo, role);
}
} catch (const std::exception &e) {
@ -179,6 +180,35 @@ SmartListModel::setConferenceableFilter(const QString &filter)
endResetModel();
}
void
SmartListModel::fillConversationsList()
{
beginResetModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
conversations_.clear();
for (auto convSearch : convModel->getAllSearchResults()) {
conversations_.emplace_back(convSearch);
}
for (auto convFilt : convModel->allFilteredConversations()) {
conversations_.emplace_back(convFilt);
}
endResetModel();
}
void
SmartListModel::updateConversation(const QString &convUid)
{
auto* convModel = LRCInstance::getCurrentConversationModel();
for (lrc::api::conversation::Info &conversation : conversations_) {
if (conversation.uid == convUid) {
conversation = convModel->getConversationForUID(convUid);
return;
}
}
}
void
SmartListModel::toggleSection(const QString &section)
{
@ -194,7 +224,7 @@ SmartListModel::toggleSection(const QString &section)
int
SmartListModel::currentUidSmartListModelIndex()
{
auto convUid = LRCInstance::getCurrentConvUid();
const auto convUid = LRCInstance::getCurrentConvUid();
for (int i = 0; i < rowCount(); i++) {
if (convUid == data(index(i, 0), Role::UID))
return i;
@ -278,17 +308,19 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
case Role::UID:
return QVariant(item.uid);
case Role::InCall: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getCurrentCallModel();
auto* callModel = LRCInstance::getCurrentCallModel();
return QVariant(callModel->hasCall(convInfo.callId));
}
return QVariant(false);
}
case Role::IsAudioOnly: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) {
auto call = LRCInstance::getCallInfoForConversation(convInfo);
auto* call = LRCInstance::getCallInfoForConversation(convInfo);
if (call) {
return QVariant(call->isAudioOnly);
}
@ -296,10 +328,11 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
return QVariant();
}
case Role::CallStackViewShouldShow: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) {
auto callModel = LRCInstance::getCurrentCallModel();
auto call = callModel->getCall(convInfo.callId);
auto* callModel = LRCInstance::getCurrentCallModel();
const auto call = callModel->getCall(convInfo.callId);
return QVariant(callModel->hasCall(convInfo.callId)
&& ((!call.isOutgoing
&& (call.status == lrc::api::call::Status::IN_PROGRESS
@ -309,9 +342,10 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
return QVariant(false);
}
case Role::CallStateStr: {
auto &convInfo = LRCInstance::getConversationFromConvUid(item.uid);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(item.uid);
if (!convInfo.uid.isEmpty()) {
auto call = LRCInstance::getCallInfoForConversation(convInfo);
auto* call = LRCInstance::getCallInfoForConversation(convInfo);
if (call) {
auto statusString = call::to_string(call->status);
return QVariant(statusString);
@ -323,7 +357,7 @@ SmartListModel::getConversationItemData(const conversation::Info &item,
return QVariant(QString());
case Role::Draft: {
if (!item.uid.isEmpty()) {
auto draft = LRCInstance::getContentDraft(item.uid, accountInfo.id);
const auto draft = LRCInstance::getContentDraft(item.uid, accountInfo.id);
if (!draft.isEmpty()) {
/*
* Pencil Emoji

View file

@ -82,6 +82,8 @@ public:
Q_INVOKABLE void setConferenceableFilter(const QString &filter = {});
Q_INVOKABLE void toggleSection(const QString &section);
Q_INVOKABLE int currentUidSmartListModelIndex();
Q_INVOKABLE void fillConversationsList();
Q_INVOKABLE void updateConversation(const QString &conv);
private:
QString accountId_;
@ -96,4 +98,5 @@ private:
Type listModelType_;
QMap<QString, bool> sectionState_;
QMap<ConferenceableItem, ConferenceableValue> conferenceables_;
ConversationModel::ConversationQueue conversations_;
};

View file

@ -616,7 +616,7 @@ Utils::isInteractionGenerated(const lrc::api::interaction::Type &type)
bool
Utils::isContactValid(const QString &contactUid, const lrc::api::ConversationModel &model)
{
auto contact = model.owner.contactModel->getContact(contactUid);
const auto contact = model.owner.contactModel->getContact(contactUid);
return (contact.profileInfo.type == lrc::api::profile::Type::PENDING
|| contact.profileInfo.type == lrc::api::profile::Type::TEMPORARY
|| contact.profileInfo.type == lrc::api::profile::Type::RING
@ -638,7 +638,8 @@ Utils::conversationPhoto(const QString &convUid,
const lrc::api::account::Info &accountInfo,
bool filtered)
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountInfo.id, filtered);
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid);
if (!convInfo.uid.isEmpty()) {
return GlobalInstances::pixmapManipulator()
.decorationRole(convInfo, accountInfo)
@ -934,17 +935,15 @@ Utils::humanFileSize(qint64 fileSize)
const QString
UtilsAdapter::getBestName(const QString &accountId, const QString &uid)
{
auto convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestNameForConversation(LRCInstance::getConversationFromConvUid(uid, accountId),
*convModel);
auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestNameForConversation(convModel->getConversationForUID(uid), *convModel);
}
const QString
UtilsAdapter::getBestId(const QString &accountId, const QString &uid)
{
auto convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestIdForConversation(LRCInstance::getConversationFromConvUid(uid, accountId),
*convModel);
auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestIdForConversation(convModel->getConversationForUID(uid), *convModel);
}
int
@ -952,11 +951,11 @@ UtilsAdapter::getTotalUnreadMessages()
{
int totalUnreadMessages{0};
if (LRCInstance::getCurrentAccountInfo().profileInfo.type != lrc::api::profile::Type::SIP) {
auto convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel();
auto ringConversations = convModel->getFilteredConversations(lrc::api::profile::Type::RING);
std::for_each(ringConversations.begin(),
ringConversations.end(),
[&totalUnreadMessages, convModel](const auto &conversation) {
[&totalUnreadMessages](const auto &conversation) {
totalUnreadMessages += conversation.unreadMessages;
});
}
@ -1009,8 +1008,8 @@ UtilsAdapter::getAccountListSize()
void
UtilsAdapter::setCurrentCall(const QString &accountId, const QString &convUid)
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto &accInfo = LRCInstance::getAccountInfo(accountId);
const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
accInfo.callModel->setCurrentCall(convInfo.callId);
}
@ -1037,7 +1036,9 @@ UtilsAdapter::hasVideoCall()
const QString
UtilsAdapter::getCallId(const QString &accountId, const QString &convUid)
{
auto convInfo = LRCInstance::getConversationFromConvUid(convUid, accountId);
auto &accInfo = LRCInstance::getAccountInfo(accountId);
const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
if (convInfo.uid.isEmpty()) {
return "";
}