removes dead code
authorbuff <andreas@pep-project.org>
Mon, 10 Sep 2018 18:14:03 +0200
changeset 63078bd7fcc42a97
parent 6306 4808ecd63114
child 6308 62e8d9011c28
removes dead code
pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Mon Sep 10 17:46:17 2018 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Mon Sep 10 18:14:03 2018 +0200
     1.3 @@ -21,18 +21,11 @@
     1.4      }
     1.5      var viewModels = [IndexPath : PrefetchableViewModel]()
     1.6  
     1.7 -    internal var model: EmailListViewModel?
     1.8 -    
     1.9 -    private let queue: OperationQueue = {
    1.10 -        let createe = OperationQueue()
    1.11 -        createe.qualityOfService = .userInteractive
    1.12 -        createe.maxConcurrentOperationCount = 5
    1.13 -        return createe
    1.14 -    }()
    1.15 -    private var operations = [IndexPath:Operation]()
    1.16 +    var model: EmailListViewModel?
    1.17 +
    1.18      public static let storyboardId = "EmailListViewController"
    1.19      private var lastSelectedIndexPath: IndexPath?
    1.20 -    
    1.21 +
    1.22      let searchController = UISearchController(searchResultsController: nil)
    1.23  
    1.24      //swipe acctions types
    1.25 @@ -41,19 +34,15 @@
    1.26  
    1.27      private var swipeDelete : SwipeAction? = nil
    1.28  
    1.29 -    /// Indicates that we must not trigger reloadData.
    1.30 -    private var loadingBlocked = false
    1.31 -
    1.32      // MARK: - Outlets
    1.33      
    1.34      @IBOutlet weak var enableFilterButton: UIBarButtonItem!
    1.35  
    1.36 -    var textFilterButton: UIBarButtonItem = UIBarButtonItem(
    1.37 -        title: "",
    1.38 -        style: .plain,
    1.39 -        target: nil,
    1.40 -        action: nil)
    1.41 -    
    1.42 +    var textFilterButton: UIBarButtonItem = UIBarButtonItem(title: "",
    1.43 +                                                            style: .plain,
    1.44 +                                                            target: nil,
    1.45 +                                                            action: nil)
    1.46 +
    1.47      // MARK: - Life Cycle
    1.48  
    1.49      override func viewDidLoad() {
    1.50 @@ -83,7 +72,7 @@
    1.51  
    1.52          if let vm = model {
    1.53              updateFilterButtonView()
    1.54 -            if vm.checkIfSettingsChanged() { //IOS-1323: off topic: This is bad.
    1.55 +            if vm.checkIfSettingsChanged() {
    1.56                  settingsChanged()
    1.57              }
    1.58          }
    1.59 @@ -92,9 +81,9 @@
    1.60      deinit {
    1.61           NotificationCenter.default.removeObserver(self)
    1.62      }
    1.63 -    
    1.64 +
    1.65      // MARK: - Setup
    1.66 -    
    1.67 +
    1.68      private func resetModel() {
    1.69          if let theFolder = folderToShow {
    1.70              model = EmailListViewModel(emailListViewModelDelegate: self,
    1.71 @@ -113,11 +102,6 @@
    1.72              // No account exists. Show account setup.
    1.73              performSegue(withIdentifier:.segueAddNewAccount, sender: self)
    1.74              return
    1.75 -        } else if let vm = model { //IOS-1323 dead code. Remove. Not using this is actually causing  IOS-1323.
    1.76 -            // We came back from e.g EmailView ...
    1.77 -            updateFilterText()
    1.78 -            // ... so we want to update "seen" status
    1.79 -            vm.reloadData()
    1.80          } else if folderToShow == nil {
    1.81              // We have not been created to show a specific folder, thus we show unified inbox
    1.82              folderToShow = UnifiedInbox()
    1.83 @@ -217,7 +201,7 @@
    1.84                                             y: searchController.searchBar.frame.size.height),
    1.85                                     animated: false)
    1.86      }
    1.87 -    
    1.88 +
    1.89      // MARK: - Other
    1.90  
    1.91      private func folderIsDraft(_ parentFolder: Folder?) -> Bool {
    1.92 @@ -469,14 +453,10 @@
    1.93      // MARK: - Action Filter Button
    1.94      
    1.95      @IBAction func filterButtonHasBeenPressed(_ sender: UIBarButtonItem) {
    1.96 -        guard !loadingBlocked else {
    1.97 -            return
    1.98 -        }
    1.99          guard let vm = model else {
   1.100              Log.shared.errorAndCrash(component: #function, errorString: "We should have a model here")
   1.101              return
   1.102          }
   1.103 -        stopLoading()
   1.104          vm.isFilterEnabled = !vm.isFilterEnabled
   1.105          if vm.isFilterEnabled {
   1.106              let flexibleSpace: UIBarButtonItem = UIBarButtonItem(
   1.107 @@ -492,13 +472,13 @@
   1.108          }
   1.109          updateFilterButtonView()
   1.110      }
   1.111 -    
   1.112 +
   1.113      private func updateFilterButtonView() {
   1.114          guard let vm = model else {
   1.115              Log.shared.errorAndCrash(component: #function, errorString: "We should have a model here")
   1.116              return
   1.117          }
   1.118 -        
   1.119 +
   1.120          textFilterButton.isEnabled = vm.isFilterEnabled
   1.121          if textFilterButton.isEnabled {
   1.122              enableFilterButton.image = UIImage(named: "unread-icon-active")
   1.123 @@ -531,8 +511,6 @@
   1.124              guard let viewModel = model?.viewModel(for: indexPath.row) else {
   1.125                  return cell
   1.126              }
   1.127 -//            viewModels[indexPath] = viewModel
   1.128 -
   1.129              theCell.configure(for:viewModel)
   1.130          } else {
   1.131              Log.shared.errorAndCrash(component: #function, errorString: "dequeued wrong cell")
   1.132 @@ -542,7 +520,7 @@
   1.133      }
   1.134  
   1.135      // MARK: - UITableViewDelegate
   1.136 -    
   1.137 +
   1.138      func tableView(_ tableView: UITableView,
   1.139                     editActionsForRowAt
   1.140          indexPath: IndexPath,
   1.141 @@ -637,7 +615,6 @@
   1.142      }
   1.143  
   1.144      override func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
   1.145 -        cancelOperation(for: indexPath)
   1.146          guard let cell = cell as? EmailListViewCell else {
   1.147              return
   1.148          }
   1.149 @@ -703,31 +680,6 @@
   1.150          }
   1.151      }
   1.152  
   1.153 -    // MARK: - Queue Handling
   1.154 -
   1.155 -    /// Cancels all operations and sets tableView.dataSource to nil.
   1.156 -    /// Used to avoid that an operation accesses an outdated view model
   1.157 -    private func stopLoading() { //IOS-1323: off topic: still all this dead is hanging around
   1.158 -        loadingBlocked = true
   1.159 -        tableView.dataSource = nil
   1.160 -        queue.cancelAllOperations()
   1.161 -        queue.waitUntilAllOperationsAreFinished()
   1.162 -    }
   1.163 -
   1.164 -    private func queue(operation op:Operation, for indexPath: IndexPath) {
   1.165 -        operations[indexPath] = op
   1.166 -        queue.addOperation(op)
   1.167 -    }
   1.168 -
   1.169 -    private func cancelOperation(for indexPath:IndexPath) { //IOS-1323: off topic: still all this dead is hanging around
   1.170 -        guard let op = operations.removeValue(forKey: indexPath) else {
   1.171 -            return
   1.172 -        }
   1.173 -        if !op.isCancelled  {
   1.174 -            op.cancel()
   1.175 -        }
   1.176 -    }
   1.177 -
   1.178      // MARK: -
   1.179  
   1.180      override func didReceiveMemoryWarning() {
   1.181 @@ -909,7 +861,6 @@
   1.182      }
   1.183  
   1.184      func updateView() {
   1.185 -        loadingBlocked = false
   1.186          tableView.dataSource = self
   1.187          tableView.reloadData()
   1.188          showNoMessageSelectedIfNeeded()