Commit 8585cc01 authored by Anthony Léonard's avatar Anthony Léonard Committed by Kateryna Kostiuk

deselect conversation when right panel disappear

When the back button is pressed, the selected conversation in the list
is now deselected. Prior to this patch, it was necessary to select
another conversation then the first one to reopen the chat view with
a contact.

Change-Id: I46a253ecd2161c76bb4d8bab26b7b1389248abc9
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 01634109
......@@ -21,6 +21,8 @@
#import <api/conversation.h>
#import <api/conversationmodel.h>
@class RingWindowController;
@interface ConversationVC : NSViewController
-(void) initFrame;
......@@ -36,4 +38,6 @@
- (void) setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel*)model;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow;
@end
......@@ -39,6 +39,7 @@
#import "AvailableAccountModel.h"
#import "MessagesVC.h"
#import "utils.h"
#import "RingWindowController.h"
#import <QuartzCore/QuartzCore.h>
......@@ -62,6 +63,8 @@
const lrc::api::conversation::Info* cachedConv_;
lrc::api::ConversationModel* convModel_;
RingWindowController* delegate;
// All those connections are needed to invalidate cached conversation as pointer
// may not be referencing the same conversation anymore
QMetaObject::Connection modelSortedConnection_, filterChangedConnection_, newConversationConnection_, conversationRemovedConnection_;
......@@ -73,6 +76,15 @@
@implementation ConversationVC
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow
{
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
delegate = mainWindow;
}
return self;
}
-(const lrc::api::conversation::Info*) getCurrentConversation
{
if (convModel_ == nil || convUid_.empty())
......@@ -191,6 +203,7 @@
}
- (IBAction)backPressed:(id)sender {
[delegate rightPanelClosed];
[self animateOut];
}
......
......@@ -49,4 +49,10 @@ namespace lrc {
*/
- (void) selectAccount:(const lrc::api::account::Info&)accInfo;
/**
* Method triggered when a panel on the right is closed by user action. It triggers any action needed
* on itself or other view controllers to react properly to this event.
*/
-(void) rightPanelClosed;
@end
......@@ -95,7 +95,7 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
lrc_ = std::make_unique<lrc::api::Lrc>();
currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil];
offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil delegate:self];
// toolbar items
chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel()) delegate:self];
contactRequestVC = [[ContactRequestVC alloc] initWithNibName:@"ContactRequest" bundle:nil];
......@@ -373,6 +373,11 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
[self updateRingID];
}
-(void)rightPanelClosed
{
[smartViewVC deselect];
}
#pragma mark - NSToolbarDelegate
- (nullable NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
......
......@@ -46,4 +46,9 @@ namespace lrc {
*/
-(void)selectConversation:(const lrc::api::conversation::Info&)conv model:(lrc::api::ConversationModel*)model;
/**
* Deselect any selected conversation
*/
-(void)deselect;
@end
......@@ -189,6 +189,12 @@ NSInteger const PRESENCE_TAG = 800;
}
}
-(void)deselect
{
selectedUid_.clear();
[smartView deselectAll:nil];
}
#pragma mark - NSTableViewDelegate methods
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
......
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