IOS-1521 adapts MM changes (rm dead code) IOS-1521+IOS-1495
authorbuff <andreas@pep-project.org>
Tue, 14 May 2019 15:59:48 +0200
branchIOS-1521+IOS-1495
changeset 861050299b427bd3
parent 8589 85b856556c62
child 8611 14e23a7f54fa
IOS-1521 adapts MM changes (rm dead code)
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/Models/Folder+Extensions.swift
pEpForiOS/UI/Filter/ViewModel/FilterCellViewModel.swift
pEpForiOS/UI/Filter/ViewModel/FilterSectionViewModel.swift
pEpForiOS/UI/Filter/ViewModel/FilterViewModel.swift
pEpForiOSTests/MessageModelTests.swift
pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModel+InitDataTest.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Mon May 13 20:30:01 2019 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Tue May 14 15:59:48 2019 +0200
     1.3 @@ -431,8 +431,6 @@
     1.4  		B776A47B223962B50047A41D /* EmailListViewModel+MessageQueryResultsDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776A47A223962B50047A41D /* EmailListViewModel+MessageQueryResultsDelegate.swift */; };
     1.5  		B78309C81EAA09040051A2E0 /* AccountCreation.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B78309C61EAA09040051A2E0 /* AccountCreation.storyboard */; };
     1.6  		B78CF8251E76D706008C1739 /* FilterTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78CF8241E76D706008C1739 /* FilterTableViewController.swift */; };
     1.7 -		B78CF8291E76E0F1008C1739 /* FilterSectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78CF8281E76E0F1008C1739 /* FilterSectionViewModel.swift */; };
     1.8 -		B78CF82B1E76E146008C1739 /* FilterCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */; };
     1.9  		B7A50746224CD27A007B988F /* FilterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7A50745224CD27A007B988F /* FilterViewModel.swift */; };
    1.10  		B7D1EEC81E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */; };
    1.11  		B7DB7FC42215C4FF003968DA /* UINavigationController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC32215C4FF003968DA /* UINavigationController+Extensions.swift */; };
    1.12 @@ -952,8 +950,6 @@
    1.13  		B776A47A223962B50047A41D /* EmailListViewModel+MessageQueryResultsDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailListViewModel+MessageQueryResultsDelegate.swift"; sourceTree = "<group>"; };
    1.14  		B78309C71EAA09040051A2E0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/AccountCreation.storyboard; sourceTree = "<group>"; };
    1.15  		B78CF8241E76D706008C1739 /* FilterTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterTableViewController.swift; path = Filter/FilterTableViewController.swift; sourceTree = "<group>"; };
    1.16 -		B78CF8281E76E0F1008C1739 /* FilterSectionViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterSectionViewModel.swift; path = Filter/ViewModel/FilterSectionViewModel.swift; sourceTree = "<group>"; };
    1.17 -		B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FilterCellViewModel.swift; path = Filter/ViewModel/FilterCellViewModel.swift; sourceTree = "<group>"; };
    1.18  		B7A50745224CD27A007B988F /* FilterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FilterViewModel.swift; path = Filter/ViewModel/FilterViewModel.swift; sourceTree = "<group>"; };
    1.19  		B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CollapsibleTableViewHeader.swift; path = Folder/CollapsibleTableViewHeader.swift; sourceTree = "<group>"; };
    1.20  		B7DB7FC32215C4FF003968DA /* UINavigationController+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extensions.swift"; sourceTree = "<group>"; };
    1.21 @@ -2435,8 +2431,6 @@
    1.22  		B78CF8271E76E0DF008C1739 /* ViewModel */ = {
    1.23  			isa = PBXGroup;
    1.24  			children = (
    1.25 -				B78CF8281E76E0F1008C1739 /* FilterSectionViewModel.swift */,
    1.26 -				B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */,
    1.27  				B7A50745224CD27A007B988F /* FilterViewModel.swift */,
    1.28  			);
    1.29  			name = ViewModel;
    1.30 @@ -2901,7 +2895,6 @@
    1.31  				152A39E421905C3E00D9F8E4 /* NSAttributedString+RecipientTextUtils.swift in Sources */,
    1.32  				00EB89AD20E3D3C200CDFA0D /* ThreadedEmailViewModel+MoveToFolderDelegate.swift in Sources */,
    1.33  				155050F21FE95D8A009CEAD2 /* UserNotificationTool+pEp.swift in Sources */,
    1.34 -				B78CF82B1E76E146008C1739 /* FilterCellViewModel.swift in Sources */,
    1.35  				43497B3A211C63CA00AC42B0 /* Message+MessageIdentitfying.swift in Sources */,
    1.36  				15874BC72127493E00A3A4A6 /* SettingDefaultAccountTableViewController.swift in Sources */,
    1.37  				4388A0E22008F813008CB98D /* (null) in Sources */,
    1.38 @@ -2989,7 +2982,6 @@
    1.39  				228038681DC9DE6D00F1CB45 /* TextfieldResponder.swift in Sources */,
    1.40  				B75FF00B1EFD420F00C57289 /* EmailListViewModel.swift in Sources */,
    1.41  				4380528B1FE3E2E800ACF729 /* OAuth2AuthorizationURLHandlerProtocol.swift in Sources */,
    1.42 -				B78CF8291E76E0F1008C1739 /* FilterSectionViewModel.swift in Sources */,
    1.43  				43293EFB1EB9DD6700EEE010 /* UIViewController+Extension.swift in Sources */,
    1.44  				152A39D521905C3E00D9F8E4 /* SubjectCellViewModel.swift in Sources */,
    1.45  				43D0702F2133DB3F0013B120 /* AppSettings.swift in Sources */,
     2.1 --- a/pEpForiOS/Models/Folder+Extensions.swift	Mon May 13 20:30:01 2019 +0200
     2.2 +++ b/pEpForiOS/Models/Folder+Extensions.swift	Tue May 14 15:59:48 2019 +0200
     2.3 @@ -8,6 +8,7 @@
     2.4  
     2.5  import MessageModel
     2.6  
     2.7 +//!!!: must be moved to MM
     2.8  extension Folder {
     2.9  
    2.10      /// Whether or not messages with PEP-Rating_none should be displayed to the user.
    2.11 @@ -21,32 +22,11 @@
    2.12          return  allMessagesNonThreaded().count //allCdMessagesCount(ignoringPepRating: showsMessagesNeverSeenByEngine) //!!!: let CD count please
    2.13      }
    2.14  
    2.15 -    public func indexOf(message: Message) -> Int? {
    2.16 -        let i2 = indexOfBinary(message: message)
    2.17 -        return i2
    2.18 -    }
    2.19 -
    2.20 +    //!!!: should become obsolete
    2.21      public func messageAt(index: Int) -> Message? {
    2.22          if let message = allMessagesNonThreaded()[safe: index] {
    2.23              return message
    2.24          }
    2.25          return nil
    2.26      }
    2.27 -
    2.28 -    private func indexOfBinary(message: Message) -> Int? {
    2.29 -        func comparator(m1: CdMessage, m2: CdMessage) -> ComparisonResult {
    2.30 -            for desc in defaultSortDescriptors() {
    2.31 -                let c1 = desc.compare(m1, to: m2)
    2.32 -                if c1 != .orderedSame {
    2.33 -                    return c1
    2.34 -                }
    2.35 -            }
    2.36 -            return .orderedSame
    2.37 -        }
    2.38 -        guard let cdMsg = CdMessage.search(message: message) else {
    2.39 -            return nil
    2.40 -        }
    2.41 -        let msgs = allCdMessages(ignoringPepRating: showsMessagesNeverSeenByEngine)
    2.42 -        return msgs.binarySearch(element: cdMsg, comparator: comparator)
    2.43 -    }
    2.44  }
     3.1 --- a/pEpForiOS/UI/Filter/ViewModel/FilterCellViewModel.swift	Mon May 13 20:30:01 2019 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,18 +0,0 @@
     3.4 -//
     3.5 -//import Foundation
     3.6 -//import MessageModel
     3.7 -//
     3.8 -//public protocol FilterCellProtocol {
     3.9 -//    var icon: UIImage { get }
    3.10 -//    var title: String { get }
    3.11 -//    var enabled: Bool { get }
    3.12 -//}
    3.13 -//
    3.14 -//public enum FilterTypeCell {
    3.15 -//    case Account, Flagg, Unread, Attachments
    3.16 -//}
    3.17 -//
    3.18 -//public struct FilterCellAccountViewModel : FilterCellProtocol {
    3.19 -//
    3.20 -//
    3.21 -//}
     4.1 --- a/pEpForiOS/UI/Filter/ViewModel/FilterSectionViewModel.swift	Mon May 13 20:30:01 2019 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,150 +0,0 @@
     4.4 -////
     4.5 -////  FilterViewModel.swift
     4.6 -////  pEpForiOS
     4.7 -////
     4.8 -////  Created by Xavier Algarra on 13/03/2017.
     4.9 -////  Copyright © 2017 p≡p Security S.A. All rights reserved.
    4.10 -////
    4.11 -//
    4.12 -//import Foundation
    4.13 -//import MessageModel
    4.14 -//import pEpIOSToolbox
    4.15 -//
    4.16 -//public enum FilterSectionType {
    4.17 -//    case accouts, include, other
    4.18 -//}
    4.19 -//public class FilterSectionViewModel {
    4.20 -//    public var title: String
    4.21 -//    public var filters: MessageQueryResultsFilter?
    4.22 -//
    4.23 -//    public init(type: FilterSectionType, filter: MessageQueryResultsFilter? = nil) {
    4.24 -//        if let previousFilter = filter {
    4.25 -//            filters = previousFilter
    4.26 -//        }
    4.27 -//        items = [FilterCellViewModel]()
    4.28 -//        switch type {
    4.29 -//        case .accouts:
    4.30 -//            self.title = NSLocalizedString("INCLUDE MAIL FROM:", comment: "title for the accounts section")
    4.31 -//            break
    4.32 -//        case .include:
    4.33 -//            self.title = NSLocalizedString("INCLUDE:", comment: "title for the include section")
    4.34 -//            break
    4.35 -//        case .other:
    4.36 -//            self.title = ""
    4.37 -//            break
    4.38 -//        }
    4.39 -//        generateCells(type: type)
    4.40 -//    }
    4.41 -//
    4.42 -//    private func generateCells(type: FilterSectionType) {
    4.43 -//        switch type {
    4.44 -//        case .accouts:
    4.45 -//            for account in Account.all() {
    4.46 -//                guard let icon = UIImage(named: "folders-icon-inbox") else {
    4.47 -//                    Log.shared.errorAndCrash("Error Loading images")
    4.48 -//                    return
    4.49 -//                }
    4.50 -//                items.append(
    4.51 -//                    FilterCellViewModel(image: icon, title: account.user.address,
    4.52 -//                                        enabled: filters?.accounts.contains(account), type: .Account))
    4.53 -//            }
    4.54 -//            break
    4.55 -//        case .include:
    4.56 -//            guard let unreadIcon = UIImage(named: "icon-unread") else {
    4.57 -//                Log.shared.errorAndCrash("Error Loading images")
    4.58 -//                return
    4.59 -//            }
    4.60 -//            items.append(
    4.61 -//                FilterCellViewModel(image: unreadIcon,
    4.62 -//                                    title: NSLocalizedString("Unread",
    4.63 -//                                                             comment: "title unread filter cell"),
    4.64 -//                                    enabled: filters?.mustBeUnread, type: .Unread))
    4.65 -//
    4.66 -//            guard let flaggedIcon = UIImage(named: "icon-flagged") else {
    4.67 -//                Log.shared.errorAndCrash("Error Loading images")
    4.68 -//                return
    4.69 -//            }
    4.70 -//            items.append(
    4.71 -//                FilterCellViewModel(image: flaggedIcon,
    4.72 -//                                    title: NSLocalizedString("Flagged",
    4.73 -//                                                             comment: "title unread filter cell"),
    4.74 -//                                    enabled: filters?.mustBeFlagged, type: .Flagg))
    4.75 -//            break
    4.76 -//        case .other:
    4.77 -//            guard let attachIcon = UIImage(named: "attachment-list-icon") else {
    4.78 -//                Log.shared.errorAndCrash("Error Loading images")
    4.79 -//                return
    4.80 -//            }
    4.81 -//            items.append(
    4.82 -//                FilterCellViewModel(image: attachIcon,
    4.83 -//                                    title: NSLocalizedString("Attachments",
    4.84 -//                                                             comment: "title attachments filter cell"),
    4.85 -//                                    enabled: filters?.mustContainAttachments, type: .Attachments))
    4.86 -//            break
    4.87 -//        }
    4.88 -//    }
    4.89 -//
    4.90 -//    func getFlagValue() -> Bool? {
    4.91 -//        for item in items {
    4.92 -//            if item.filterType == FilterTypeCell.Flagg {
    4.93 -//                return item.enabled
    4.94 -//            }
    4.95 -//        }
    4.96 -//        return nil
    4.97 -//    }
    4.98 -//
    4.99 -//    func getUnreadValue() -> Bool? {
   4.100 -//        for item in items {
   4.101 -//            if item.filterType == FilterTypeCell.Unread {
   4.102 -//                return item.enabled
   4.103 -//            }
   4.104 -//        }
   4.105 -//        return nil
   4.106 -//    }
   4.107 -//
   4.108 -//    func getAttachmentsValue() -> Bool? {
   4.109 -//        for item in items {
   4.110 -//            if item.filterType == FilterTypeCell.Attachments {
   4.111 -//                return item.enabled
   4.112 -//            }
   4.113 -//        }
   4.114 -//        return nil
   4.115 -//    }
   4.116 -//
   4.117 -//    func getAccountsValue() -> [Account] {
   4.118 -//        for item in items {
   4.119 -//            <#code#>
   4.120 -//        }
   4.121 -//    }
   4.122 -//
   4.123 -//    func accountsEnabled() -> Int {
   4.124 -//        var accountsSelected = 0
   4.125 -//        for filter in items {
   4.126 -//            if(filter.enabled) {
   4.127 -//                accountsSelected += 1
   4.128 -//            }
   4.129 -//        }
   4.130 -//        return accountsSelected
   4.131 -//    }
   4.132 -//
   4.133 -//    @available(*, deprecated)
   4.134 -//    func getInvalidFilters() -> CompositeFilter<FilterBase> {
   4.135 -//        let filter = CompositeFilter<FilterBase>()
   4.136 -//        for item in items {
   4.137 -//            if !item.enabled {
   4.138 -//                //filter.add(filter: item.filter)
   4.139 -//            }
   4.140 -//        }
   4.141 -//        return filter
   4.142 -//    }
   4.143 -//
   4.144 -//    subscript(index: Int) -> FilterCellViewModel {
   4.145 -//        get {
   4.146 -//            return self.items[index]
   4.147 -//        }
   4.148 -//    }
   4.149 -//    var count : Int {
   4.150 -//        return self.items.count
   4.151 -//    }
   4.152 -//}
   4.153 -//
     5.1 --- a/pEpForiOS/UI/Filter/ViewModel/FilterViewModel.swift	Mon May 13 20:30:01 2019 +0200
     5.2 +++ b/pEpForiOS/UI/Filter/ViewModel/FilterViewModel.swift	Tue May 14 15:59:48 2019 +0200
     5.3 @@ -150,7 +150,6 @@
     5.4          case .account:
     5.5              guard let accountAddress = account?.user.address else {
     5.6                  Log.shared.errorAndCrash("Error generating row")
     5.7 -                //!!!: it is posible to get in there?
     5.8                  return ""
     5.9              }
    5.10              return accountAddress
     6.1 --- a/pEpForiOSTests/MessageModelTests.swift	Mon May 13 20:30:01 2019 +0200
     6.2 +++ b/pEpForiOSTests/MessageModelTests.swift	Tue May 14 15:59:48 2019 +0200
     6.3 @@ -7,7 +7,7 @@
     6.4  //
     6.5  
     6.6  import pEpForiOS
     6.7 -import MessageModel
     6.8 +@testable import MessageModel
     6.9  
    6.10  import XCTest
    6.11  
     7.1 --- a/pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModel+InitDataTest.swift	Mon May 13 20:30:01 2019 +0200
     7.2 +++ b/pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModel+InitDataTest.swift	Tue May 14 15:59:48 2019 +0200
     7.3 @@ -9,7 +9,7 @@
     7.4  import XCTest
     7.5  
     7.6  @testable import pEpForiOS
     7.7 -import MessageModel
     7.8 +@testable import MessageModel
     7.9  
    7.10  class ComposeViewModel_InitDataTest: CoreDataDrivenTestBase {
    7.11      var inbox: Folder?