IOS-233: method for detecting if folder is already selected
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 20 Jul 2017 12:58:30 +0200
changeset 244656ad0bae7b3a
parent 2445 735a8f3c685a
child 2447 eb6ba6a520fa
IOS-233: method for detecting if folder is already selected
pEpForiOS/Network/ImapService.swift
     1.1 --- a/pEpForiOS/Network/ImapService.swift	Thu Jul 20 12:45:31 2017 +0200
     1.2 +++ b/pEpForiOS/Network/ImapService.swift	Thu Jul 20 12:58:30 2017 +0200
     1.3 @@ -88,6 +88,18 @@
     1.4          }
     1.5      }
     1.6  
     1.7 +    func isAlreadySelected(folderName: String) -> Bool {
     1.8 +        if let currentFolderName = imapState.currentFolder?.name() {
     1.9 +            if currentFolderName.isInboxFolderName() && folderName.isInboxFolderName() {
    1.10 +                return true
    1.11 +            }
    1.12 +            if currentFolderName == folderName {
    1.13 +                return true
    1.14 +            }
    1.15 +        }
    1.16 +        return false
    1.17 +    }
    1.18 +
    1.19      override func createService() -> CWService {
    1.20          return CWIMAPStore(name: connectInfo.networkAddress,
    1.21                             port: UInt32(connectInfo.networkPort),
    1.22 @@ -393,3 +405,12 @@
    1.23          delegate?.folderAppendFailed(self, notification: notification)
    1.24      }
    1.25  }
    1.26 +
    1.27 +extension String {
    1.28 +    func isInboxFolderName() -> Bool {
    1.29 +        if lowercased() == ImapSync.defaultImapInboxName.lowercased() {
    1.30 +            return true
    1.31 +        }
    1.32 +        return false
    1.33 +    }
    1.34 +}