IOS-1323 fixes: viewed message imediatelly dismissed
authorbuff <andreas@pep-project.org>
Mon, 10 Sep 2018 17:44:06 +0200
changeset 6305744deada71a8
parent 6304 a011b0068596
child 6306 4808ecd63114
IOS-1323 fixes: viewed message imediatelly dismissed
pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Mon Sep 10 16:13:59 2018 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Mon Sep 10 17:44:06 2018 +0200
     1.3 @@ -264,7 +264,6 @@
     1.4          } else {
     1.5              performSegue(withIdentifier: SegueIdentifier.segueShowEmail, sender: self)
     1.6          }
     1.7 -        //        vm.markRead(forIndexPath: indexPath) //IOS-1323:
     1.8      }
     1.9  
    1.10      private func showNoMessageSelectedIfNeeded() {
    1.11 @@ -272,7 +271,13 @@
    1.12              return
    1.13          }
    1.14          if splitViewController.isCollapsed {
    1.15 -            if navigationController?.topViewController != self {
    1.16 +            guard let vm = model else {
    1.17 +                Log.shared.errorAndCrash(component: #function, errorString: "Invalid state")
    1.18 +                return
    1.19 +            }
    1.20 +            let unreadFilterActive = vm.isFilterEnabled &&
    1.21 +                vm.activeFilter?.contains(type: UnreadFilter.self) ?? false
    1.22 +            if navigationController?.topViewController != self && !unreadFilterActive {
    1.23                  navigationController?.popViewController(animated: true)
    1.24              }
    1.25          } else {
    1.26 @@ -294,7 +299,7 @@
    1.27      var readToolbarButton : UIBarButtonItem?
    1.28      var unreadToolbarButton : UIBarButtonItem?
    1.29      var deleteToolbarButton : UIBarButtonItem?
    1.30 -    var moveToolbarButton : UIBarButtonItem?
    1.31 +    var moveToolbarButton : UIBarButtonItem? //IOS-1323: off topic: fix style
    1.32  
    1.33      @IBAction func Edit(_ sender: Any) {
    1.34  
    1.35 @@ -868,18 +873,25 @@
    1.36  
    1.37      func emailListViewModel(viewModel: EmailListViewModel,
    1.38                              didChangeSeenStateForDataAt indexPaths: [IndexPath]) {
    1.39 -        //IOS-1323:
    1.40          guard let isIphone = splitViewController?.isCollapsed, let vm = model else {
    1.41              Log.shared.errorAndCrash(component: #function, errorString: "Invalid state")
    1.42              return
    1.43          }
    1.44 -        if !isIphone && vm.isFilterEnabled && vm.activeFilter?.contains(type: UnreadFilter.self) ?? false {
    1.45 +        let unreadFilterActive = vm.isFilterEnabled &&
    1.46 +            vm.activeFilter?.contains(type: UnreadFilter.self) ?? false
    1.47 +
    1.48 +        // If unread filter is active, /seen state updates require special handling ...
    1.49 +
    1.50 +        if !isIphone && unreadFilterActive {
    1.51              // We do not update the seen status when both spitview views are shown and the list is
    1.52              // currently filtered by unread.
    1.53              return
    1.54 +        } else if isIphone && unreadFilterActive {
    1.55 +            vm.reloadData()
    1.56 +        } else {
    1.57 +          //  ... otherwize we forward to update
    1.58 +           emailListViewModel(viewModel: viewModel, didUpdateDataAt: indexPaths)
    1.59          }
    1.60 -        // Forward to update
    1.61 -        emailListViewModel(viewModel: viewModel, didUpdateDataAt: indexPaths)
    1.62      }
    1.63  
    1.64      func emailListViewModel(viewModel: EmailListViewModel,