//
//  LoginCoordinator.swift
//  TweetsCounter
//
//  Created by Patrick Balestra on 12/1/16.
//  Copyright © 2016 Patrick Balestra. All rights reserved.
//

import UIKit

protocol LoginCoordinatorDelegate: class {
    func dismiss()
}

final class LoginCoordinator: Coordinator, LoginCoordinatorDelegate {

    lazy var controller: LoginViewController = {
        return StoryboardScene.Main.LoginViewController()
    }()
    var childCoordinators = Array<AnyObject>()

    let homeController: HomeViewController
    let linkOpener = LinkOpener()

    init(parent: HomeViewController) {
        self.homeController = parent
        linkOpener.coordinator = self
    }

    func start() {
        controller.coordinator = self
        homeController.present(controller, animated: true)
    }

    // MARK: Coordinator
    
    func presentSafari(_ url: URL) {
        let safari = linkOpener.openInSafari(url)
        controller.present(safari, animated: true, completion: nil)
    }

    // MARK: LoginCoordinatorDelegate

    func dismiss() {
        controller.dismiss(animated: true)
        homeController.refreshTimeline()
        homeController.requestProfilePicture()
    }
}

//
//  LoginCoordinator.swift
//  TweetsCounter
//
//  Created by Patrick Balestra on 12/1/16.
//  Copyright © 2016 Patrick Balestra. All rights reserved.
//

import UIKit

protocol LoginCoordinatorDelegate: class {
    func dismiss()
}

final class LoginCoordinator: Coordinator, LoginCoordinatorDelegate {

    lazy var controller: LoginViewController = {
        return StoryboardScene.Main.LoginViewController()
    }()
    var childCoordinators = Array<AnyObject>()

    let parent: HomeViewController
    let linkOpener = LinkOpener()

    init(parent: HomeViewController) {
        self.parent = parent
        linkOpener.coordinator = self
    }

    func start() {
        controller.coordinator = self
        parent.present(controller, animated: true)
    }

    // MARK: Coordinator
    
    func presentSafari(_ url: URL) {
        let safari = linkOpener.openInSafari(url)
        controller.present(safari, animated: true, completion: nil)
    }

    // MARK: LoginCoordinatorDelegate

    func dismiss() {
        controller.dismiss(animated: true)
        parent.refreshTimeline()
    }
}

--- 
+++ 
@@ -19,17 +19,17 @@
     }()
     var childCoordinators = Array<AnyObject>()
 
-    let parent: HomeViewController
+    let homeController: HomeViewController
     let linkOpener = LinkOpener()
 
     init(parent: HomeViewController) {
-        self.parent = parent
+        self.homeController = parent
         linkOpener.coordinator = self
     }
 
     func start() {
         controller.coordinator = self
-        parent.present(controller, animated: true)
+        homeController.present(controller, animated: true)
     }
 
     // MARK: Coordinator
@@ -43,6 +43,7 @@
 
     func dismiss() {
         controller.dismiss(animated: true)
-        parent.refreshTimeline()
+        homeController.refreshTimeline()
+        homeController.requestProfilePicture()
     }
 }
Fix user profile picture not being loaded after logging in
