IOS-1368 guard insted of if to enseure cell is present IOS-1368
authorXavier Algarra <xavier@pep-project.org>
Thu, 04 Jul 2019 15:35:35 +0200
branchIOS-1368
changeset 930294e47f560bc6
parent 9218 59fbd2459896
child 9303 fe87d91e2615
IOS-1368 guard insted of if to enseure cell is present
pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Wed Jun 26 06:36:16 2019 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewController.swift	Thu Jul 04 15:35:35 2019 +0200
     1.3 @@ -921,20 +921,16 @@
     1.4          }
     1.5  
     1.6          return UIAlertAction(title: title, style: .default) { [weak self] action in
     1.7 -            guard let me = self else {
     1.8 +            guard let me = self, let cell = me.tableView.cellForRow(at: indexPath) as? EmailListViewCell else {
     1.9                  Log.shared.errorAndCrash("Lost MySelf")
    1.10                  return
    1.11              }
    1.12              if seenState {
    1.13                  me.model?.markSelectedAsUnread(indexPaths: [indexPath])
    1.14 -                if let cell = me.tableView.cellForRow(at: indexPath) as? EmailListViewCell {
    1.15 -                    cell.isSeen = false
    1.16 -                }
    1.17 +                cell.isSeen = false
    1.18              } else {
    1.19                  me.model?.markSelectedAsRead(indexPaths: [indexPath])
    1.20 -                if let cell = me.tableView.cellForRow(at: indexPath) as? EmailListViewCell {
    1.21 -                    cell.isSeen = true
    1.22 -                }
    1.23 +                cell.isSeen = true
    1.24              }
    1.25          }
    1.26      }