Commit 22ce9365 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk

fix: update smart list with a new conversation

When temporary conversation became permanent update smart list
and reselect conversation.

Change-Id: I5d6251ed4f24c4aba1e71fd7b16de7bf1388cff4
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent ab499f4b
......@@ -48,7 +48,6 @@
QMetaObject::Connection modelSortedSignal_;
QMetaObject::Connection filterChangedSignal_;
QMetaObject::Connection interactionStatusUpdatedSignal_;
QMetaObject::Connection newConversationConnection;
}
@property (nonatomic, strong, readonly) INDSequentialTextSelectionManager* selectionManager;
......@@ -90,7 +89,6 @@ NSInteger const GENERIC_INT_TEXT_TAG = 100;
// Signal triggered when messages are received or their status updated
QObject::disconnect(newInteractionSignal_);
QObject::disconnect(interactionStatusUpdatedSignal_);
QObject::disconnect(newConversationConnection);
newInteractionSignal_ = QObject::connect(convModel_, &lrc::api::ConversationModel::newInteraction,
[self](const std::string& uid, uint64_t interactionId, const lrc::api::interaction::Info& interaction){
if (uid != convUid_)
......@@ -107,10 +105,6 @@ NSInteger const GENERIC_INT_TEXT_TAG = 100;
[conversationView reloadData];
[conversationView scrollToEndOfDocument:nil];
});
newConversationConnection = QObject::connect(convModel_, &lrc::api::ConversationModel::newConversation,
[self](const std::string& uid){
convUid_ = uid;
});
// Signals tracking changes in conversation list, we need them as cached conversation can be invalid
// after a reordering.
......
......@@ -172,8 +172,6 @@ NSInteger const REQUEST_SEG = 1;
if (it != model_->allFilteredConversations().end()) {
NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:(it - model_->allFilteredConversations().begin())];
[smartView selectRowIndexes:indexSet byExtendingSelection:NO];
} else {
selectedUid_.clear();
}
}
......@@ -220,8 +218,9 @@ NSInteger const REQUEST_SEG = 1;
[self reloadData];
});
newConversationConnection_ = QObject::connect(model_, &lrc::api::ConversationModel::newConversation,
[self] (){
[self] (const std::string& uid) {
[self reloadData];
[self updateConversationForNewContact:[NSString stringWithUTF8String:uid.c_str()]];
});
conversationRemovedConnection_ = QObject::connect(model_, &lrc::api::ConversationModel::conversationRemoved,
[self] (){
......@@ -481,6 +480,26 @@ NSInteger const REQUEST_SEG = 1;
[self processSearchFieldInput];
}
-(void)updateConversationForNewContact:(NSString *)uId {
if (model_ == nil) {
return;
}
[self clearSearchField];
auto uid = std::string([uId UTF8String]);
auto it = getConversationFromUid(uid, *model_);
if (it != model_->allFilteredConversations().end()) {
@try {
auto contact = model_->owner.contactModel->getContact(it->participants[0]);
if (!contact.profileInfo.uri.empty() && contact.profileInfo.uri.compare(selectedUid_) == 0) {
selectedUid_ = uid;
model_->selectConversation(uid);
}
} @catch (NSException *exception) {
return;
}
}
}
/**
Copy a NSString in the general Pasteboard
......@@ -520,7 +539,6 @@ NSInteger const REQUEST_SEG = 1;
selectedUid_ = uid;
model_->selectConversation(uid);
[self.view.window makeFirstResponder: smartView];
searchField.stringValue = @"";
return YES;
} @catch (NSException *exception) {
return YES;
......
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