IOS-1323 the delegate must know what changed
authorbuff <andreas@pep-project.org>
Mon, 10 Sep 2018 15:10:39 +0200
changeset 6301d07245a10abe
parent 6300 7ba3e48efada
child 6302 16f88dce4b8f
IOS-1323 the delegate must know what changed
pEpForiOS/UI/EmailDisplayList/EmailListViewModel+EmailDisplayDelegate.swift
     1.1 --- a/pEpForiOS/UI/EmailDisplayList/EmailListViewModel+EmailDisplayDelegate.swift	Mon Sep 10 15:09:36 2018 +0200
     1.2 +++ b/pEpForiOS/UI/EmailDisplayList/EmailListViewModel+EmailDisplayDelegate.swift	Mon Sep 10 15:10:39 2018 +0200
     1.3 @@ -31,7 +31,7 @@
     1.4      }
     1.5  
     1.6      func emailDisplayDidChangeMarkSeen(message: Message) {
     1.7 -        updateRow(for: message)
     1.8 +        updateRow(for: message, isSeenStateChange: true)
     1.9      }
    1.10  
    1.11      private func deleteRow(for message: Message) {
    1.12 @@ -47,7 +47,7 @@
    1.13          startListeningToChanges()
    1.14      }
    1.15  
    1.16 -    private func updateRow(for message: Message) {
    1.17 +    private func updateRow(for message: Message, isSeenStateChange: Bool = false) {
    1.18          stopListeningToChanges()
    1.19          defer {
    1.20              startListeningToChanges()
    1.21 @@ -58,8 +58,12 @@
    1.22          
    1.23          let previewMessage = MessageViewModel(with: message)
    1.24          messages.removeObject(at: index)
    1.25 -        _ = messages.insert(object: previewMessage)
    1.26 -        informUpdateRow(at: index)
    1.27 +        messages.insert(object: previewMessage)
    1.28 +        if isSeenStateChange {
    1.29 +            informSeenStateChangeForRow(at: index)
    1.30 +        } else {
    1.31 +            informUpdateRow(at: index)
    1.32 +        }
    1.33      }
    1.34  
    1.35      private func informUpdateRow(at index: Int) {
    1.36 @@ -68,6 +72,12 @@
    1.37                                                         didUpdateDataAt: [indexPath])
    1.38      }
    1.39  
    1.40 +    private func informSeenStateChangeForRow(at index: Int) {
    1.41 +        let indexPath = self.indexPath(for: index)
    1.42 +        emailListViewModelDelegate?.emailListViewModel(viewModel: self,
    1.43 +                                                       didChangeSeenStateForDataAt: [indexPath])
    1.44 +    }
    1.45 +
    1.46      private func informDeleteRow(at index: Int) {
    1.47          let indexPath = IndexPath(row: index, section: 0)
    1.48