зеркало из https://github.com/nextcloud/talk-ios.git
fixed SettingsViewController not updating after clearing caches
Fixes #1791 Signed-off-by: Daniel Standfest <daniel@standfest.io>
This commit is contained in:
Родитель
f6f93ea915
Коммит
d3d1d5bbfd
|
@ -120,18 +120,8 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(contactsAccessHasBeenUpdated(notification:)), name: NSNotification.Name.NCContactsManagerContactsAccessUpdated, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(userProfileImageUpdated), name: NSNotification.Name.NCUserProfileImageUpdated, object: nil)
|
||||
|
||||
let imageCacheSize = NCImageSessionManager.shared.cache.currentDiskUsage
|
||||
let sdImageCacheSize = SDImageCache.shared.totalDiskSize()
|
||||
self.totalImageCacheSize = imageCacheSize + Int(sdImageCacheSize)
|
||||
|
||||
let fileController = NCChatFileController()
|
||||
let talkAccounts = NCDatabaseManager.sharedInstance().allAccounts()
|
||||
|
||||
if let talkAccounts = talkAccounts as? [TalkAccount] {
|
||||
for account in talkAccounts {
|
||||
self.totalFileCacheSize += Int(fileController.getDiskUsage(for: account))
|
||||
}
|
||||
}
|
||||
self.updateTotalImageCacheSize()
|
||||
self.updateTotalFileCacheSize()
|
||||
|
||||
self.adaptInterfaceForAppState(appState: NCConnectionController.sharedInstance().appState)
|
||||
}
|
||||
|
@ -556,9 +546,10 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U
|
|||
NCImageSessionManager.shared.cache.removeAllCachedResponses()
|
||||
|
||||
SDImageCache.shared.clearMemory()
|
||||
SDImageCache.shared.clearDisk()
|
||||
|
||||
self.tableView.reloadData()
|
||||
SDImageCache.shared.clearDisk {
|
||||
self.updateTotalImageCacheSize()
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
clearCacheDialog.addAction(clearAction)
|
||||
|
||||
|
@ -584,6 +575,7 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U
|
|||
}
|
||||
}
|
||||
|
||||
self.updateTotalFileCacheSize()
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
clearCacheDialog.addAction(clearAction)
|
||||
|
@ -1025,4 +1017,23 @@ extension SettingsTableViewController {
|
|||
|
||||
return NCAPIController.sharedInstance().userProfileImage(for: account, with: self.traitCollection.userInterfaceStyle)
|
||||
}
|
||||
|
||||
func updateTotalImageCacheSize() {
|
||||
let imageCacheSize = NCImageSessionManager.shared.cache.currentDiskUsage
|
||||
let sdImageCacheSize = SDImageCache.shared.totalDiskSize()
|
||||
self.totalImageCacheSize = imageCacheSize + Int(sdImageCacheSize)
|
||||
}
|
||||
|
||||
func updateTotalFileCacheSize() {
|
||||
self.totalFileCacheSize = 0
|
||||
|
||||
let fileController = NCChatFileController()
|
||||
let talkAccounts = NCDatabaseManager.sharedInstance().allAccounts()
|
||||
|
||||
if let talkAccounts = talkAccounts as? [TalkAccount] {
|
||||
for account in talkAccounts {
|
||||
self.totalFileCacheSize += Int(fileController.getDiskUsage(for: account))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче