pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
changeset 2362 9aeaabed0d07
parent 2345 4dd2c835d36f
child 2363 e969a926d09b
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Fri Jun 23 14:34:09 2017 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Wed Jun 28 18:51:01 2017 +0200
     1.3 @@ -25,8 +25,8 @@
     1.4          var isSynching: Bool = false
     1.5      }
     1.6  
     1.7 -    //var viewModel = EmailListViewModel()
     1.8      var config: EmailListConfig?
     1.9 +    var viewModel: EmailListViewModel?
    1.10      var state = UIState()
    1.11      let searchController = UISearchController(searchResultsController: nil)
    1.12      let cellsInUse = NSCache<NSString, EmailListViewCell>()
    1.13 @@ -68,8 +68,8 @@
    1.14              fol.updateLastLookAt()
    1.15          }
    1.16  
    1.17 +        viewModel = EmailListViewModel(config: config)
    1.18          MessageModelConfig.messageFolderDelegate = self
    1.19 -
    1.20          
    1.21      }
    1.22  
    1.23 @@ -87,6 +87,7 @@
    1.24              config = EmailListConfig(appConfig: appDelegate.appConfig,
    1.25                                       folder: Folder.unifiedInbox())
    1.26          }
    1.27 +
    1.28          if Account.all().isEmpty {
    1.29              performSegue(withIdentifier:.segueAddNewAccount, sender: self)
    1.30          }
    1.31 @@ -142,15 +143,15 @@
    1.32      // MARK: - UITableViewDataSource
    1.33  
    1.34      override func numberOfSections(in tableView: UITableView) -> Int {
    1.35 -        if let _ = config?.folder {
    1.36 +        if let _ = viewModel?.folderToShow {
    1.37              return 1
    1.38          }
    1.39          return 0
    1.40      }
    1.41  
    1.42      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    1.43 -        if let fol = config?.folder  {
    1.44 -            return fol.messageCount()
    1.45 +        if let vm = viewModel {
    1.46 +            return vm.count
    1.47          }
    1.48          return 0
    1.49      }
    1.50 @@ -161,7 +162,8 @@
    1.51              withIdentifier: "EmailListViewCell", for: indexPath) as! EmailListViewCell
    1.52          //mantener el configure cell para tal de no generar un vm para celdas
    1.53          if let message = cell.configureCell(config: config, indexPath: indexPath) {
    1.54 -            associate(message: message, toCell: cell)
    1.55 +            viewModel?.associate(cell: cell, position: indexPath.row)
    1.56 +            //associate(message: message, toCell: cell)
    1.57          }
    1.58          return cell
    1.59      }