IOS-596 filter reload correctly
authorXavier Algarra <xavier@pep-project.org>
Thu, 20 Jul 2017 12:45:31 +0200
changeset 2445735a8f3c685a
parent 2444 de9e98a0d4dd
child 2446 56ad0bae7b3a
IOS-596 filter reload correctly
pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
pEpForiOS/UI/Filter/FilterTableViewController.swift
pEpForiOS/UI/Filter/ViewModel/FilterCellViewModel.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Thu Jul 20 11:51:45 2017 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Thu Jul 20 12:45:31 2017 +0200
     1.3 @@ -399,7 +399,7 @@
     1.4              if let destiny = segue.destination as? FilterTableViewController {
     1.5                  destiny.filterDelegate = self.viewModel
     1.6                  destiny.inFolder = false
     1.7 -                destiny.filterEnabled = self.config?.folder?.filter as! Filter?
     1.8 +                destiny.filterEnabled = self.viewModel?.folderToShow?.filter
     1.9                  destiny.hidesBottomBarWhenPushed = true
    1.10              }
    1.11              break
     2.1 --- a/pEpForiOS/UI/Filter/FilterTableViewController.swift	Thu Jul 20 11:51:45 2017 +0200
     2.2 +++ b/pEpForiOS/UI/Filter/FilterTableViewController.swift	Thu Jul 20 12:45:31 2017 +0200
     2.3 @@ -24,11 +24,6 @@
     2.4          let newBackButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.back(sender:)))
     2.5          self.navigationItem.leftBarButtonItem = newBackButton
     2.6  
     2.7 -        // Uncomment the following line to preserve selection between presentations
     2.8 -        // self.clearsSelectionOnViewWillAppear = false
     2.9 -
    2.10 -        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    2.11 -        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    2.12      }
    2.13  
    2.14      func back(sender: UIBarButtonItem) {
    2.15 @@ -49,6 +44,7 @@
    2.16      }
    2.17  
    2.18      func initViewModel() {
    2.19 +
    2.20          if !inFolder {
    2.21              sections.append(FilterViewModel(type: .accouts, filter: filterEnabled))
    2.22          }
     3.1 --- a/pEpForiOS/UI/Filter/ViewModel/FilterCellViewModel.swift	Thu Jul 20 11:51:45 2017 +0200
     3.2 +++ b/pEpForiOS/UI/Filter/ViewModel/FilterCellViewModel.swift	Thu Jul 20 12:45:31 2017 +0200
     3.3 @@ -38,8 +38,8 @@
     3.4              }
     3.5              icon = image
     3.6              title = NSLocalizedString("Unread", comment: "title unread filter cell")
     3.7 +            enabled = filter?.ofType(type: .unread) ?? false
     3.8              filter = Filter.unread()
     3.9 -            enabled = filter?.ofType(type: .unread) ?? false
    3.10  
    3.11          case .flagged:
    3.12              guard let image = FlagImages.create(imageSize: circleSize).flaggedImage else {
    3.13 @@ -48,24 +48,16 @@
    3.14              }
    3.15              icon = image
    3.16              title = NSLocalizedString("Flagged", comment: "title unread filter cell")
    3.17 +            enabled = filter?.ofType(type: .flagged) ?? false
    3.18              filter = Filter.flagged()
    3.19 -            enabled = filter?.ofType(type: .flagged) ?? false
    3.20  
    3.21          case .attachment:
    3.22              self.icon = UIImage(named: "attachment-list-icon")!
    3.23              self.title = NSLocalizedString("Attachments", comment: "title attachments filter cell")
    3.24 +            enabled = filter?.ofType(type: .attachment) ?? false
    3.25              filter = Filter.attachment()
    3.26 -            enabled = filter?.ofType(type: .attachment) ?? false
    3.27  
    3.28 -        case .search:
    3.29 -            self.icon = FlagImages.create(imageSize: squareSize).notSeenImage
    3.30 -            self.title = ""
    3.31 -
    3.32 -        case .unified:
    3.33 -            self.icon = FlagImages.create(imageSize: squareSize).notSeenImage
    3.34 -            self.title = ""
    3.35 -
    3.36 -        case .account:
    3.37 +        default:
    3.38              self.icon = FlagImages.create(imageSize: squareSize).notSeenImage
    3.39              self.title = ""
    3.40          }