Fix code style & unnecessary changes
This commit is contained in:
parent
81bdf7911e
commit
a9f81a17f9
|
@ -40,15 +40,15 @@ final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControll
|
||||||
|
|
||||||
init(sessionID: String) {
|
init(sessionID: String) {
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
enterPublicKeyVC.setSessionID(sessionID: sessionID)
|
enterPublicKeyVC.setSessionID(to: sessionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
override init(nibName: String?, bundle: Bundle?) {
|
||||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
super.init(nibName: nibName, bundle: bundle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Lifecycle
|
// MARK: Lifecycle
|
||||||
|
@ -217,10 +217,6 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
return result
|
return result
|
||||||
}()
|
}()
|
||||||
|
|
||||||
func setSessionID(sessionID: String){
|
|
||||||
self.publicKeyTextView.insertText(sessionID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Lifecycle
|
// MARK: Lifecycle
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
// Remove background color
|
// Remove background color
|
||||||
|
@ -277,6 +273,10 @@ private final class EnterPublicKeyVC : UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: General
|
// MARK: General
|
||||||
|
func setSessionID(to sessionID: String){
|
||||||
|
publicKeyTextView.text = sessionID
|
||||||
|
}
|
||||||
|
|
||||||
func constrainHeight(to height: CGFloat) {
|
func constrainHeight(to height: CGFloat) {
|
||||||
view.set(.height, to: height)
|
view.set(.height, to: height)
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
explanationLabel.text = NSLocalizedString("vc_home_empty_state_message", comment: "")
|
explanationLabel.text = NSLocalizedString("vc_home_empty_state_message", comment: "")
|
||||||
let createNewPrivateChatButton = Button(style: .prominentOutline, size: .large)
|
let createNewPrivateChatButton = Button(style: .prominentOutline, size: .large)
|
||||||
createNewPrivateChatButton.setTitle(NSLocalizedString("vc_home_empty_state_button_title", comment: ""), for: UIControl.State.normal)
|
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)
|
createNewPrivateChatButton.set(.width, to: 196)
|
||||||
let result = UIStackView(arrangedSubviews: [ explanationLabel, createNewPrivateChatButton ])
|
let result = UIStackView(arrangedSubviews: [ explanationLabel, createNewPrivateChatButton ])
|
||||||
result.axis = .vertical
|
result.axis = .vertical
|
||||||
|
@ -385,11 +385,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
} else if let thread = thread as? TSGroupThread, thread.isClosedGroup == true {
|
} else if let thread = thread as? TSGroupThread, thread.isClosedGroup == true {
|
||||||
let groupID = thread.groupModel.groupId
|
let groupID = thread.groupModel.groupId
|
||||||
let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
|
let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
|
||||||
do {
|
MessageSender.leave(groupPublicKey, using: transaction).retainUntilComplete()
|
||||||
try MessageSender.leave(groupPublicKey, using: transaction)
|
|
||||||
} catch {
|
|
||||||
// TODO: Handle
|
|
||||||
}
|
|
||||||
thread.removeAllThreadInteractions(with: transaction)
|
thread.removeAllThreadInteractions(with: transaction)
|
||||||
thread.remove(with: transaction)
|
thread.remove(with: transaction)
|
||||||
} else {
|
} else {
|
||||||
|
@ -423,7 +419,8 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
||||||
present(navigationController, animated: true, completion: nil)
|
present(navigationController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func createNewDM(sessionID: String) {
|
@objc(createNewDMFromDeepLink:)
|
||||||
|
func createNewDMFromDeepLink(sessionID: String) {
|
||||||
let newDMVC = NewDMVC(sessionID: sessionID)
|
let newDMVC = NewDMVC(sessionID: sessionID)
|
||||||
let navigationController = OWSNavigationController(rootViewController: newDMVC)
|
let navigationController = OWSNavigationController(rootViewController: newDMVC)
|
||||||
present(navigationController, animated: true, completion: nil)
|
present(navigationController, animated: true, completion: nil)
|
||||||
|
|
|
@ -218,7 +218,6 @@ protocol NewConversationButtonSetDelegate {
|
||||||
|
|
||||||
func joinOpenGroup()
|
func joinOpenGroup()
|
||||||
func createNewDM()
|
func createNewDM()
|
||||||
func createNewDM(sessionID: String)
|
|
||||||
func createClosedGroup()
|
func createClosedGroup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -790,41 +790,35 @@ static NSTimeInterval launchStartedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
# pragma mark - App Link
|
# pragma mark - App Link
|
||||||
- (BOOL)application:(UIApplication *)app
|
|
||||||
openURL:(NSURL *)incomingURL
|
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
|
||||||
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
|
// URL Scheme is sessionmessenger://DM?sessionID=1234
|
||||||
// We can later add more parameters like message etc.
|
// We can later add more parameters like message etc.
|
||||||
NSString *intent = components.host;
|
NSString *intent = components.host;
|
||||||
if(intent != nil){
|
if (intent != nil && [intent isEqualToString:@"DM"]) {
|
||||||
//Handle DM
|
NSArray<NSURLQueryItem*> *params = [components queryItems];
|
||||||
if([intent isEqualToString: @"DM"]){
|
NSPredicate *sessionIDPredicate = [NSPredicate predicateWithFormat:@"name == %@", @"sessionID"];
|
||||||
NSArray<NSURLQueryItem*> *params = [components queryItems];
|
NSArray<NSURLQueryItem*> *matches = [params filteredArrayUsingPredicate:sessionIDPredicate];
|
||||||
NSPredicate *sessionIDPredicate = [NSPredicate predicateWithFormat:@"name == %@", @"sessionID"];
|
if (matches.count > 0) {
|
||||||
NSArray<NSURLQueryItem*> *matches = [params filteredArrayUsingPredicate: sessionIDPredicate];
|
NSString *sessionID = matches.firstObject.value;
|
||||||
if(matches.count > 0){
|
[self createNewDMFromDeepLink:sessionID];
|
||||||
NSString *sessionID = matches.firstObject.value;
|
return YES;
|
||||||
if(sessionID != nil){
|
|
||||||
[self handleDM: sessionID];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleDM:(NSString *)sessionID
|
- (void)createNewDMFromDeepLink:(NSString *)sessionID
|
||||||
{
|
{
|
||||||
UIViewController *viewController = self.window.rootViewController;
|
UIViewController *viewController = self.window.rootViewController;
|
||||||
if([viewController class] == [OWSNavigationController class]){
|
if ([viewController class] == [OWSNavigationController class]) {
|
||||||
UIViewController *rVC = ((OWSNavigationController *)viewController).visibleViewController;
|
UIViewController *visibleVC = ((OWSNavigationController *)viewController).visibleViewController;
|
||||||
if([rVC class] == [HomeVC class]){
|
if ([visibleVC isKindOfClass:HomeVC.class]) {
|
||||||
HomeVC *homeVC = (HomeVC *)rVC;
|
HomeVC *homeVC = (HomeVC *)visibleVC;
|
||||||
[homeVC createNewDMWithSessionID: sessionID];
|
[homeVC createNewDMFromDeepLink:sessionID];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue