IOS-444 correctly deleting expunged messages
authorDirk Zimmermann <dirk@pep-project.org>
Tue, 14 Feb 2017 12:43:54 +0100
changeset 1693c4db2ce1f89b
parent 1692 13af947e3b63
child 1694 898bb5eaa391
IOS-444 correctly deleting expunged messages
pEpForiOS/Background/SyncMessagesOperation.swift
pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
     1.1 --- a/pEpForiOS/Background/SyncMessagesOperation.swift	Tue Feb 14 12:43:53 2017 +0100
     1.2 +++ b/pEpForiOS/Background/SyncMessagesOperation.swift	Tue Feb 14 12:43:54 2017 +0100
     1.3 @@ -106,19 +106,13 @@
     1.4          let messages = CdMessage.all(
     1.5              predicate: NSCompoundPredicate(
     1.6                  andPredicateWithSubpredicates: [p1, p2])) as? [CdMessage] ?? []
     1.7 -        var deletedMessage = false
     1.8          for msg in messages {
     1.9              if !existingUIDs.contains(NSNumber(value: msg.uid)) {
    1.10                  Log.info(component: comp,
    1.11                           content: "removing message UID \(msg.uid) messageID \(msg.uuid)")
    1.12 -                msg.delete()
    1.13 -                CdHeaderField.deleteOrphans()
    1.14 -                deletedMessage = true
    1.15 +                msg.deleteAndInformDelegate(context: context)
    1.16              }
    1.17          }
    1.18 -        if deletedMessage {
    1.19 -            Record.saveAndWait(context: context)
    1.20 -        }
    1.21      }
    1.22  }
    1.23  
     2.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Tue Feb 14 12:43:53 2017 +0100
     2.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Tue Feb 14 12:43:54 2017 +0100
     2.3 @@ -385,16 +385,11 @@
     2.4                          tableView.reloadData()
     2.5                      }
     2.6                  } else if msg.isGhost {
     2.7 -                    var found = false
     2.8                      if let cell = cellsByMessageID.object(forKey: msg.uuid as NSString) {
     2.9                          if let ip = tableView.indexPath(for: cell) {
    2.10 -                            found = true
    2.11                              tableView.deleteRows(at: [ip], with: .automatic)
    2.12                          }
    2.13                      }
    2.14 -                    if !found {
    2.15 -                        tableView.reloadData()
    2.16 -                    }
    2.17                  } else {
    2.18                      // other flags than delete must have been changed
    2.19                      if let cell = cellsByMessageID.object(forKey: msg.uuid as NSString) {