pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
branchtmp-fix-dangling-head
changeset 2838 5210d224f53c
parent 2818 91e41e9e4b4f
child 2845 1db827abc7c8
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Wed Aug 23 12:08:15 2017 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Wed Aug 23 18:34:08 2017 +0200
     1.3 @@ -12,15 +12,15 @@
     1.4  import MessageModel
     1.5  
     1.6  struct EmailListConfig {
     1.7 -    var appConfig: AppConfig?
     1.8 -
     1.9 +    var appConfig: AppConfig
    1.10      /** The folder to display, if it exists */
    1.11      var folder: Folder?
    1.12  
    1.13      let imageProvider = IdentityImageProvider()
    1.14  }
    1.15  
    1.16 -class EmailListViewController: UITableViewController {
    1.17 +class EmailListViewController: TableViewControllerBase {
    1.18 +    public static let storyboardId = "EmailListViewController"
    1.19      struct UIState {
    1.20          var isSynching: Bool = false
    1.21      }
    1.22 @@ -46,6 +46,15 @@
    1.23      override func viewDidLoad() {
    1.24          super.viewDidLoad()
    1.25  
    1.26 +        // As this is the initial VC, we have to set the config here once.
    1.27 +        // Better abbroach would be to init initial VC progamatically in AppDelegate, but that failed 
    1.28 +        // due to references to mainStoryboard.initialViewController from other Storyboards.
    1.29 +        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
    1.30 +            Log.shared.errorAndCrash(component: #function, errorString: "App without delegate?")
    1.31 +            return
    1.32 +        }
    1.33 +        appConfig = appDelegate.appConfig
    1.34 +
    1.35          title = NSLocalizedString("Inbox", comment: "General name for (unified) inbox")
    1.36          UIHelper.emailListTableHeight(self.tableView)
    1.37          addSearchBar()
    1.38 @@ -82,7 +91,7 @@
    1.39          } else {
    1.40              self.showFoldersButton.isEnabled = true
    1.41          }
    1.42 -        
    1.43 +
    1.44      }
    1.45  
    1.46      private func updateLastLookAt(on folder: Folder) {
    1.47 @@ -99,12 +108,12 @@
    1.48      }
    1.49  
    1.50      func setupConfig() {
    1.51 -        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
    1.52 -            Log.shared.errorAndCrash(component: #function, errorString: "No AppDelegate?")
    1.53 +        guard let saveAppConfig = appConfig else {
    1.54 +            Log.shared.errorAndCrash(component: #function, errorString: "No AppConfig!")
    1.55              return
    1.56          }
    1.57          if config == nil {
    1.58 -            config = EmailListConfig(appConfig: appDelegate.appConfig,
    1.59 +            config = EmailListConfig(appConfig: saveAppConfig,
    1.60                                       folder: Folder.unifiedInbox())
    1.61          }
    1.62  
    1.63 @@ -192,7 +201,7 @@
    1.64          let cell = tableView.dequeueReusableCell(
    1.65              withIdentifier: "EmailListViewCell", for: indexPath) as! EmailListViewCell
    1.66          //mantener el configure cell para tal de no generar un vm para celdas
    1.67 -        let _ = cell.configureCell(config: config, indexPath: indexPath)
    1.68 +        let _ = cell.configureCell(config: config, indexPath: indexPath, session: session)
    1.69          viewModel?.associate(cell: cell, position: indexPath.row)
    1.70          return cell
    1.71      }
    1.72 @@ -430,6 +439,7 @@
    1.73              break
    1.74          case .segueFilter:
    1.75              if let destiny = segue.destination as? FilterTableViewController {
    1.76 +                destiny.appConfig = self.appConfig
    1.77                  destiny.filterDelegate = self.viewModel
    1.78                  destiny.inFolder = false
    1.79                  destiny.filterEnabled = self.viewModel?.folderToShow?.filter
    1.80 @@ -449,9 +459,8 @@
    1.81          case .segueEditAccounts, .segueCompose, .noSegue:
    1.82              break
    1.83          }
    1.84 +    }
    1.85  
    1.86 -    }
    1.87 -    
    1.88      @IBAction func segueUnwindAccountAdded(segue: UIStoryboardSegue) {
    1.89      }
    1.90