Add delete from disk
This commit is contained in:
parent
ea906de576
commit
f5523dd610
@ -110,6 +110,22 @@ public final class AccountManager: UnreadCountProvider {
|
||||
return account
|
||||
}
|
||||
|
||||
public func deleteAccount(_ account: Account) {
|
||||
|
||||
accountsDictionary.removeValue(forKey: account.accountID)
|
||||
|
||||
do {
|
||||
try FileManager.default.removeItem(atPath: account.dataFolder)
|
||||
}
|
||||
catch {
|
||||
assertionFailure("Could not create folder for OnMyMac account.")
|
||||
abort()
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(name: .AccountsDidChangeNotification, object: self)
|
||||
|
||||
}
|
||||
|
||||
public func existingAccount(with accountID: String) -> Account? {
|
||||
|
||||
return accountsDictionary[accountID]
|
||||
|
@ -53,7 +53,7 @@ Aw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="create:" target="-2" id="Kjr-mt-Yp3"/>
|
||||
<action selector="delete:" target="-2" id="5zX-jC-oWO"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="v9D-u4-Ucr">
|
||||
|
@ -39,8 +39,11 @@ class AccountsDeleteWindowController: NSWindowController {
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
|
||||
}
|
||||
|
||||
@IBAction func create(_ sender: Any) {
|
||||
|
||||
@IBAction func delete(_ sender: Any) {
|
||||
guard let account = account else {
|
||||
return
|
||||
}
|
||||
AccountManager.shared.deleteAccount(account)
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user