Fix code style & unnecessary changes

This commit is contained in:
nielsandriesse 2021-06-03 11:39:52 +10:00
parent 81bdf7911e
commit a9f81a17f9
4 changed files with 31 additions and 41 deletions

View File

@ -40,15 +40,15 @@ final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControll
init(sessionID: String) {
super.init(nibName: nil, bundle: nil)
enterPublicKeyVC.setSessionID(sessionID: sessionID)
enterPublicKeyVC.setSessionID(to: sessionID)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
override init(nibName: String?, bundle: Bundle?) {
super.init(nibName: nibName, bundle: bundle)
}
// MARK: Lifecycle
@ -217,10 +217,6 @@ private final class EnterPublicKeyVC : UIViewController {
return result
}()
func setSessionID(sessionID: String){
self.publicKeyTextView.insertText(sessionID);
}
// MARK: Lifecycle
override func viewDidLoad() {
// Remove background color
@ -277,6 +273,10 @@ private final class EnterPublicKeyVC : UIViewController {
}
// MARK: General
func setSessionID(to sessionID: String){
publicKeyTextView.text = sessionID
}
func constrainHeight(to height: CGFloat) {
view.set(.height, to: height)
}

View File

@ -66,7 +66,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
explanationLabel.text = NSLocalizedString("vc_home_empty_state_message", comment: "")
let createNewPrivateChatButton = Button(style: .prominentOutline, size: .large)
createNewPrivateChatButton.setTitle(NSLocalizedString("vc_home_empty_state_button_title", comment: ""), for: UIControl.State.normal)
createNewPrivateChatButton.addTarget(self, action: #selector(createNewDM as () -> Void), for: UIControl.Event.touchUpInside)
createNewPrivateChatButton.addTarget(self, action: #selector(createNewDM), for: UIControl.Event.touchUpInside)
createNewPrivateChatButton.set(.width, to: 196)
let result = UIStackView(arrangedSubviews: [ explanationLabel, createNewPrivateChatButton ])
result.axis = .vertical
@ -385,11 +385,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
} else if let thread = thread as? TSGroupThread, thread.isClosedGroup == true {
let groupID = thread.groupModel.groupId
let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
do {
try MessageSender.leave(groupPublicKey, using: transaction)
} catch {
// TODO: Handle
}
MessageSender.leave(groupPublicKey, using: transaction).retainUntilComplete()
thread.removeAllThreadInteractions(with: transaction)
thread.remove(with: transaction)
} else {
@ -423,7 +419,8 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
present(navigationController, animated: true, completion: nil)
}
@objc func createNewDM(sessionID: String) {
@objc(createNewDMFromDeepLink:)
func createNewDMFromDeepLink(sessionID: String) {
let newDMVC = NewDMVC(sessionID: sessionID)
let navigationController = OWSNavigationController(rootViewController: newDMVC)
present(navigationController, animated: true, completion: nil)

View File

@ -218,7 +218,6 @@ protocol NewConversationButtonSetDelegate {
func joinOpenGroup()
func createNewDM()
func createNewDM(sessionID: String)
func createClosedGroup()
}

View File

@ -790,41 +790,35 @@ static NSTimeInterval launchStartedAt;
}
# pragma mark - App Link
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)incomingURL
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
NSURLComponents *components = [[NSURLComponents alloc] initWithURL:incomingURL resolvingAgainstBaseURL: true];
NSURLComponents *components = [[NSURLComponents alloc] initWithURL:url resolvingAgainstBaseURL:true];
// URL Scheme is sessionmessenger://DM?sessionID=1234
// We can later add more parameters like message etc.
NSString *intent = components.host;
if(intent != nil){
//Handle DM
if([intent isEqualToString: @"DM"]){
NSArray<NSURLQueryItem*> *params = [components queryItems];
NSPredicate *sessionIDPredicate = [NSPredicate predicateWithFormat:@"name == %@", @"sessionID"];
NSArray<NSURLQueryItem*> *matches = [params filteredArrayUsingPredicate: sessionIDPredicate];
if(matches.count > 0){
NSString *sessionID = matches.firstObject.value;
if(sessionID != nil){
[self handleDM: sessionID];
return true;
}
}
if (intent != nil && [intent isEqualToString:@"DM"]) {
NSArray<NSURLQueryItem*> *params = [components queryItems];
NSPredicate *sessionIDPredicate = [NSPredicate predicateWithFormat:@"name == %@", @"sessionID"];
NSArray<NSURLQueryItem*> *matches = [params filteredArrayUsingPredicate:sessionIDPredicate];
if (matches.count > 0) {
NSString *sessionID = matches.firstObject.value;
[self createNewDMFromDeepLink:sessionID];
return YES;
}
}
return false;
return NO;
}
- (void)handleDM:(NSString *)sessionID
- (void)createNewDMFromDeepLink:(NSString *)sessionID
{
UIViewController *viewController = self.window.rootViewController;
if([viewController class] == [OWSNavigationController class]){
UIViewController *rVC = ((OWSNavigationController *)viewController).visibleViewController;
if([rVC class] == [HomeVC class]){
HomeVC *homeVC = (HomeVC *)rVC;
[homeVC createNewDMWithSessionID: sessionID];
if ([viewController class] == [OWSNavigationController class]) {
UIViewController *visibleVC = ((OWSNavigationController *)viewController).visibleViewController;
if ([visibleVC isKindOfClass:HomeVC.class]) {
HomeVC *homeVC = (HomeVC *)visibleVC;
[homeVC createNewDMFromDeepLink:sessionID];
}
}
}