IOS-100 logging to track inconsistent number of cells in update
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 10 Feb 2017 17:13:38 +0100
changeset 16788eb2c23637d6
parent 1677 f5e20b03c815
child 1679 19f9739a28b0
IOS-100 logging to track inconsistent number of cells in update
pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
pEpForiOS/Util/Log.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Fri Feb 10 17:13:37 2017 +0100
     1.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Fri Feb 10 17:13:38 2017 +0100
     1.3 @@ -19,6 +19,9 @@
     1.4  }
     1.5  
     1.6  class EmailListViewController: UITableViewController {
     1.7 +    /** For debug output */
     1.8 +    let compMessageCount = "messageCount"
     1.9 +
    1.10      struct UIState {
    1.11          var isSynching: Bool = false
    1.12      }
    1.13 @@ -103,6 +106,7 @@
    1.14  
    1.15      override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    1.16          if let fol = config?.folder  {
    1.17 +            Log.info(component: #function, content: "\(compMessageCount) \(fol.messageCount())")
    1.18              return fol.messageCount()
    1.19          }
    1.20          return 0
    1.21 @@ -380,7 +384,13 @@
    1.22                      // new message has arrived
    1.23                      if let index = folder.indexOf(message: msg) {
    1.24                          let ip = IndexPath(row: index, section: 0)
    1.25 +                        Log.info(
    1.26 +                            component: #function,
    1.27 +                            content: "\(compMessageCount) inserting at \(ip), current \(tableView.numberOfRows(inSection: 0))")
    1.28                          tableView.insertRows(at: [ip], with: .automatic)
    1.29 +                        Log.info(
    1.30 +                            component: #function,
    1.31 +                            content: "\(compMessageCount) now \(tableView.numberOfRows(inSection: 0))")
    1.32                      } else {
    1.33                          tableView.reloadData()
    1.34                      }
    1.35 @@ -407,14 +417,9 @@
    1.36  
    1.37  extension EmailListViewController: MessageFolderDelegate {
    1.38      func didChange(messageFolder: MessageFolder) {
    1.39 -        if let msg = messageFolder as? Message {
    1.40 -            if msg.isOriginal {
    1.41 -                Log.info(component: #function, content: "new message")
    1.42 -            } else {
    1.43 -                Log.info(component: #function, content: "flag changes?")
    1.44 -            }
    1.45 -        }
    1.46          GCD.onMainWait {
    1.47 +            Log.info(component: #function,
    1.48 +                     content: "\(self.compMessageCount) \(self.config?.folder?.messageCount())")
    1.49              self.didChangeInternal(messageFolder: messageFolder)
    1.50          }
    1.51      }
     2.1 --- a/pEpForiOS/Util/Log.swift	Fri Feb 10 17:13:37 2017 +0100
     2.2 +++ b/pEpForiOS/Util/Log.swift	Fri Feb 10 17:13:38 2017 +0100
     2.3 @@ -26,7 +26,7 @@
     2.4      }
     2.5  
     2.6      private func saveLog(entity: String, description: String, comment: String) {
     2.7 -        queue.async {
     2.8 +        queue.sync {
     2.9              if self.logEnabled {
    2.10                  #if DEBUG_LOGGING
    2.11                      print("\(entity): \(description)")