<commit_before>//
//  MainViewController.swift
//  Rocket.Chat
//
//  Created by <NAME> on 7/8/16.
//  Copyright © 2016 Rocket.Chat. All rights reserved.
//

import UIKit

final class MainViewController: BaseViewController, AuthManagerInjected, SubscriptionManagerInjected, UserManagerInjected, PushManagerInjected {

    var injectionContainer: InjectionContainer!

    @IBOutlet weak var labelAuthenticationStatus: UILabel!
    @IBOutlet weak var buttonConnect: UIButton!

    var activityIndicator: LoaderView!
    @IBOutlet weak var activityIndicatorContainer: UIView! {
        didSet {
            let width = activityIndicatorContainer.bounds.width
            let height = activityIndicatorContainer.bounds.height
            let frame = CGRect(x: 0, y: 0, width: width, height: height)
            let activityIndicator = LoaderView(frame: frame)
            activityIndicatorContainer.addSubview(activityIndicator)
            self.activityIndicator = activityIndicator
        }
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
        self.injectionContainer = appDelegate.injectionContainer

        if authManager.isAuthenticated() == nil {
            performSegue(withIdentifier: "Auth", sender: nil)
        }
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        if let auth = authManager.isAuthenticated() {
            labelAuthenticationStatus.isHidden = true
            buttonConnect.isHidden = true
            activityIndicator.startAnimating()

            self.authManager.resume(auth, completion: { [weak self] response in
                guard let strongSelf = self else { return }
                guard !response.isError() else {
                    strongSelf.labelAuthenticationStatus.isHidden = false
                    strongSelf.buttonConnect.isHidden = false
                    strongSelf.activityIndicator.stopAnimating()
                    return
                }<commit_msg>fix: inject dependency repository into MainViewController on awaken from NIB<commit_after>//
//  MainViewController.swift
//  Rocket.Chat
//
//  Created by <NAME> on 7/8/16.
//  Copyright © 2016 Rocket.Chat. All rights reserved.
//

import UIKit

final class MainViewController: BaseViewController, AuthManagerInjected, SubscriptionManagerInjected, UserManagerInjected, PushManagerInjected {

    var injectionContainer: InjectionContainer!

    @IBOutlet weak var labelAuthenticationStatus: UILabel!
    @IBOutlet weak var buttonConnect: UIButton!

    var activityIndicator: LoaderView!
    @IBOutlet weak var activityIndicatorContainer: UIView! {
        didSet {
            let width = activityIndicatorContainer.bounds.width
            let height = activityIndicatorContainer.bounds.height
            let frame = CGRect(x: 0, y: 0, width: width, height: height)
            let activityIndicator = LoaderView(frame: frame)
            activityIndicatorContainer.addSubview(activityIndicator)
            self.activityIndicator = activityIndicator
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()

        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
        self.injectionContainer = appDelegate.injectionContainer
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        if authManager.isAuthenticated() == nil {
            performSegue(withIdentifier: "Auth", sender: nil)
        }
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        if let auth = authManager.isAuthenticated() {
            labelAuthenticationStatus.isHidden = true
            buttonConnect.isHidden = true
            activityIndicator.startAnimating()

            self.authManager.resume(auth, completion: { [weak self] response in
                guard let strongSelf = self else { return }
                guard !response.isError() else {
                    strongSelf.labelAuthenticationStatus.isHidden = false
                    strongSelf.buttonConnect.isHidden = false
                    strongSelf.activityIndicator.stopAnimating()
                    return
                }
{'fraction_non_alphanumeric': 0.07198532783127005, 'fraction_numerical': 0.004585052728106373, 'mean_word_length': 2.5529315960912053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5556027', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1066, 'n_words': 271}