Skip to content

Commit

Permalink
DON'T INSTALL: NEW CHAT VIEW
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Nov 27, 2024
1 parent 05ddf79 commit 7d43f9c
Show file tree
Hide file tree
Showing 5 changed files with 679 additions and 37 deletions.
45 changes: 22 additions & 23 deletions Monal/Classes/ActiveChatsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#import "ActiveChatsViewController.h"
#import "DataLayer.h"
#import "xmpp.h"
#import "MLNotificationManager.h"
#import "MLXMPPManager.h"
#import "MLContactCell.h"
#import "chatViewController.h"
#import "MonalAppDelegate.h"
#import "MLImageManager.h"
#import "MLXEPSlashMeHandler.h"
Expand Down Expand Up @@ -1047,26 +1048,28 @@ -(void) presentChatWithContact:(MLContact*) contact andCompletion:(monal_id_bloc
completion(@NO);
return;
}


//this will open the chat
monal_void_block_t presentator = ^{
UIViewController* chatView = [[SwiftuiInterface new] makeChatViewFor:contact];
chatView.ml_disposeCallback = ^{
[self sheetDismissed];
};
[self scrollToContact:contact];
[self showDetailViewController:chatView sender:self];
if(completion != nil)
completion(@YES);
};

//open chat (make sure we have an active buddy for it and add it to our ui, if needed)
//but don't animate this if the contact is already present in our list
[[DataLayer sharedInstance] addActiveBuddies:contact.contactJid forAccount:contact.accountID];
if([[self getChatArrayForSection:pinnedChats] containsObject:contact] || [[self getChatArrayForSection:unpinnedChats] containsObject:contact])
{
[self scrollToContact:contact];
[self performSegueWithIdentifier:@"showConversation" sender:contact];
if(completion != nil)
completion(@YES);
}
presentator();
else
{
[self insertOrMoveContact:contact completion:^(BOOL finished __unused) {
[self scrollToContact:contact];
[self performSegueWithIdentifier:@"showConversation" sender:contact];
if(completion != nil)
completion(@YES);
presentator();
}];
}
}];
}];
}
Expand Down Expand Up @@ -1103,15 +1106,7 @@ -(void) performSegueWithIdentifier:(NSString*) identifier sender:(id) sender
-(void) prepareForSegue:(UIStoryboardSegue*) segue sender:(id) sender
{
DDLogInfo(@"Got segue identifier '%@'", segue.identifier);
if([segue.identifier isEqualToString:@"showConversation"])
{
UINavigationController* nav = segue.destinationViewController;
chatViewController* chatVC = (chatViewController*)nav.topViewController;
UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = barButtonItem;
[chatVC setupWithContact:sender];
}
else if([segue.identifier isEqualToString:@"showDetails"])
if([segue.identifier isEqualToString:@"showDetails"])
{
UIViewController* detailsViewController = [[SwiftuiInterface new] makeContactDetails:sender];
detailsViewController.ml_disposeCallback = ^{
Expand Down Expand Up @@ -1527,13 +1522,17 @@ -(void) dismissRecursorWithViewControllers:(NSMutableArray*) viewControllers ani

-(chatViewController* _Nullable) currentChatView
{
//TODO: this has to be adapted to the new chatui
return nil;
/*
NSArray* controllers = ((UINavigationController*)self.splitViewController.viewControllers[0]).viewControllers;
chatViewController* chatView = nil;
if(controllers.count > 1)
chatView = [((UINavigationController*)controllers[1]).viewControllers firstObject];
if(![chatView isKindOfClass:NSClassFromString(@"chatViewController")])
chatView = nil;
return chatView;
*/
}

-(void) scrollToContact:(MLContact*) contact
Expand Down
Loading

0 comments on commit 7d43f9c

Please sign in to comment.