Commit 3b98eb89 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk

fix: prevent confetti smartlist selection when updating contacts

- needs https://gerrit-ring.savoirfairelinux.com/#/c/9195/

Change-Id: I9befd3c88c05d51a705843c4f32108ec8dc374a3
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 2efc5a92
......@@ -56,7 +56,7 @@
__strong IBOutlet NSSegmentedControl *listTypeSelector;
bool selectorIsPresent;
QMetaObject::Connection modelSortedConnection_, filterChangedConnection_, newConversationConnection_, conversationRemovedConnection_, interactionStatusUpdatedConnection_, conversationClearedConnection;
QMetaObject::Connection modelSortedConnection_, modelUpdatedConnection_, filterChangedConnection_, newConversationConnection_, conversationRemovedConnection_, interactionStatusUpdatedConnection_, conversationClearedConnection;
NSTimer* statusUpdateDebounceTimer;
lrc::api::ConversationModel* model_;
......@@ -128,6 +128,7 @@ NSInteger const REQUEST_SEG = 1;
-(void) reloadData
{
NSLog(@"reload");
[smartView deselectAll:nil];
if (!model_->owner.contactModel->hasPendingRequests()) {
......@@ -176,6 +177,18 @@ NSInteger const REQUEST_SEG = 1;
[smartView scrollToBeginningOfDocument:nil];
}
-(void) reloadConversationWithUid:(NSString *)uid
{
if (model_ != nil) {
auto it = getConversationFromUid(std::string([uid UTF8String]), *model_);
if (it != model_->allFilteredConversations().end()) {
NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:(it - model_->allFilteredConversations().begin())];
NSLog(@"reloadConversationWithUid: %@", uid);
[smartView reloadDataForRowIndexes:indexSet
columnIndexes:[NSIndexSet indexSetWithIndex:0]];
}
}
}
- (BOOL)setConversationModel:(lrc::api::ConversationModel *)conversationModel
{
......@@ -183,6 +196,7 @@ NSInteger const REQUEST_SEG = 1;
model_ = conversationModel;
selectedUid_.clear(); // Clear selected conversation as the selected account is being changed
QObject::disconnect(modelSortedConnection_);
QObject::disconnect(modelUpdatedConnection_);
QObject::disconnect(filterChangedConnection_);
QObject::disconnect(newConversationConnection_);
QObject::disconnect(conversationRemovedConnection_);
......@@ -194,6 +208,10 @@ NSInteger const REQUEST_SEG = 1;
[self] (){
[self reloadData];
});
modelUpdatedConnection_ = QObject::connect(model_, &lrc::api::ConversationModel::conversationUpdated,
[self] (const std::string& uid){
[self reloadConversationWithUid: [NSString stringWithUTF8String:uid.c_str()]];
});
filterChangedConnection_ = QObject::connect(model_, &lrc::api::ConversationModel::filterChanged,
[self] (){
[self reloadData];
......@@ -353,13 +371,13 @@ NSInteger const REQUEST_SEG = 1;
[((ContextualTableCellView*) result) setContextualsControls:controls];
[((ContextualTableCellView*) result) setShouldBlurParentView:YES];
// if (auto call = RecentModel::instance().getActiveCall(qIdx)) {
// [details setStringValue:call->roleData((int)Ring::Role::FormattedState).toString().toNSString()];
// [((ContextualTableCellView*) result) setActiveState:YES];
// } else {
// [details setStringValue:qIdx.data((int)Ring::Role::FormattedLastUsed).toString().toNSString()];
// [((ContextualTableCellView*) result) setActiveState:NO];
// }
// if (auto call = RecentModel::instance().getActiveCall(qIdx)) {
// [details setStringValue:call->roleData((int)Ring::Role::FormattedState).toString().toNSString()];
// [((ContextualTableCellView*) result) setActiveState:YES];
// } else {
// [details setStringValue:qIdx.data((int)Ring::Role::FormattedLastUsed).toString().toNSString()];
// [((ContextualTableCellView*) result) setActiveState:NO];
// }
NSTextField* unreadCount = [result viewWithTag:TXT_BUTTON_TAG];
[unreadCount setHidden:(conversation.unreadMessages == 0)];
......
......@@ -26,6 +26,11 @@
*/
@property (nonatomic) NSMutableArray* contextualsControls;
/**
* BOOL tracking if the mouse is hovering over the cell
*/
@property (nonatomic) BOOL isMouseOver;
/**
* BOOL specifying if controls should be presented when mouse is hover
*/
......
......@@ -31,7 +31,6 @@
@implementation ContextualTableCellView
- (void)updateTrackingAreas {
[super updateTrackingAreas];
[self ensureTrackingArea];
......@@ -51,6 +50,10 @@
- (void)prepareForReuse
{
if (self.isMouseOver) {
return;
}
for (NSView* item in self.contextualsControls) {
[item setHidden:YES];
if(self.shouldBlurParentView && [item respondsToSelector:@selector(vibrantView)] && item.vibrantView)
......@@ -60,6 +63,8 @@
- (void)mouseEntered:(NSEvent *)theEvent
{
self.isMouseOver = true;
if (self.activeState)
return;
......@@ -94,6 +99,8 @@
- (void)mouseExited:(NSEvent *)theEvent
{
self.isMouseOver = false;
for (NSView* item in self.contextualsControls) {
[item setHidden:YES];
if(self.shouldBlurParentView && [item respondsToSelector:@selector(vibrantView)] && item.vibrantView) {
......
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