From f5523dd610bd301dd8d9f9107666d75140c32469 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 1 May 2019 19:22:07 -0500 Subject: [PATCH] Add delete from disk --- Frameworks/Account/AccountManager.swift | 16 ++++++++++++++++ Mac/Preferences/Accounts/AccountsDelete.xib | 2 +- .../AccountsDeleteWindowController.swift | 7 +++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Frameworks/Account/AccountManager.swift b/Frameworks/Account/AccountManager.swift index 84c3a12af..e70ae561f 100644 --- a/Frameworks/Account/AccountManager.swift +++ b/Frameworks/Account/AccountManager.swift @@ -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] diff --git a/Mac/Preferences/Accounts/AccountsDelete.xib b/Mac/Preferences/Accounts/AccountsDelete.xib index 9c924fa14..cd351f1ee 100644 --- a/Mac/Preferences/Accounts/AccountsDelete.xib +++ b/Mac/Preferences/Accounts/AccountsDelete.xib @@ -53,7 +53,7 @@ Aw - +