IOS-1323 ignore seen state change on iPad if unread filter is enabled
authorbuff <andreas@pep-project.org>
Mon, 10 Sep 2018 16:13:59 +0200
changeset 6304a011b0068596
parent 6303 7324ec2c2b8c
child 6305 744deada71a8
IOS-1323 ignore seen state change on iPad if unread filter is enabled
pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Mon Sep 10 15:12:19 2018 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Mon Sep 10 16:13:59 2018 +0200
     1.3 @@ -47,7 +47,7 @@
     1.4      // MARK: - Outlets
     1.5      
     1.6      @IBOutlet weak var enableFilterButton: UIBarButtonItem!
     1.7 -    //@IBOutlet weak var textFilterButton: UIBarButtonItem!
     1.8 +    //@IBOutlet weak var textFilterButton: UIBarButtonItem! //IOS-1323: off topic: cleanup
     1.9  
    1.10      var textFilterButton: UIBarButtonItem = UIBarButtonItem(
    1.11          title: "",
    1.12 @@ -264,7 +264,7 @@
    1.13          } else {
    1.14              performSegue(withIdentifier: SegueIdentifier.segueShowEmail, sender: self)
    1.15          }
    1.16 -        vm.markRead(forIndexPath: indexPath)
    1.17 +        //        vm.markRead(forIndexPath: indexPath) //IOS-1323:
    1.18      }
    1.19  
    1.20      private func showNoMessageSelectedIfNeeded() {
    1.21 @@ -866,13 +866,19 @@
    1.22          }
    1.23      }
    1.24  
    1.25 -    func emailListViewModel(viewModel: EmailListViewModel, didChangeSeenStateForDataAt indexPaths: [IndexPath]) {
    1.26 +    func emailListViewModel(viewModel: EmailListViewModel,
    1.27 +                            didChangeSeenStateForDataAt indexPaths: [IndexPath]) {
    1.28          //IOS-1323:
    1.29 -        guard let displayMode = splitViewController?.displayMode, displayMode == .primaryHidden
    1.30 -            else {
    1.31 -                // We do not update the seen status when both spitview views are shown.
    1.32 -                return
    1.33 +        guard let isIphone = splitViewController?.isCollapsed, let vm = model else {
    1.34 +            Log.shared.errorAndCrash(component: #function, errorString: "Invalid state")
    1.35 +            return
    1.36          }
    1.37 +        if !isIphone && vm.isFilterEnabled && vm.activeFilter?.contains(type: UnreadFilter.self) ?? false {
    1.38 +            // We do not update the seen status when both spitview views are shown and the list is
    1.39 +            // currently filtered by unread.
    1.40 +            return
    1.41 +        }
    1.42 +        // Forward to update
    1.43          emailListViewModel(viewModel: viewModel, didUpdateDataAt: indexPaths)
    1.44      }
    1.45