Compare commits
2 Commits
e581f384e4
...
35a510e8ed
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 35a510e8ed | |
Shadowfacts | 0582812563 |
|
@ -30,6 +30,10 @@ class MastodonController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func resetAll() {
|
||||||
|
all = [:]
|
||||||
|
}
|
||||||
|
|
||||||
private let transient: Bool
|
private let transient: Bool
|
||||||
private(set) lazy var persistentContainer = MastodonCachePersistentStore(for: accountInfo, transient: transient)
|
private(set) lazy var persistentContainer = MastodonCachePersistentStore(for: accountInfo, transient: transient)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
static let showPostsImage = UIImage(systemName: "eye.fill")!
|
static let showPostsImage = UIImage(systemName: "eye.fill")!
|
||||||
static let hidePostsImage = UIImage(systemName: "eye.slash.fill")!
|
static let hidePostsImage = UIImage(systemName: "eye.slash.fill")!
|
||||||
|
|
||||||
let mastodonController: MastodonController
|
weak var mastodonController: MastodonController!
|
||||||
|
|
||||||
let mainStatusID: String
|
let mainStatusID: String
|
||||||
let mainStatusState: StatusState
|
let mainStatusState: StatusState
|
||||||
|
@ -43,8 +43,9 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
guard let persistentContainer = mastodonController?.persistentContainer else { return }
|
||||||
for (id, _) in statuses {
|
for (id, _) in statuses {
|
||||||
mastodonController.persistentContainer.status(for: id)?.decrementReferenceCount()
|
persistentContainer.status(for: id)?.decrementReferenceCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Pachyderm
|
||||||
|
|
||||||
class ExploreViewController: EnhancedTableViewController {
|
class ExploreViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
let mastodonController: MastodonController
|
weak var mastodonController: MastodonController!
|
||||||
|
|
||||||
var dataSource: DataSource!
|
var dataSource: DataSource!
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
private let followRequestCell = "followRequestCell"
|
private let followRequestCell = "followRequestCell"
|
||||||
private let unknownCell = "unknownCell"
|
private let unknownCell = "unknownCell"
|
||||||
|
|
||||||
let mastodonController: MastodonController
|
weak var mastodonController: MastodonController!
|
||||||
|
|
||||||
let excludedTypes: [Pachyderm.Notification.Kind]
|
let excludedTypes: [Pachyderm.Notification.Kind]
|
||||||
let groupTypes = [Notification.Kind.favourite, .reblog, .follow]
|
let groupTypes = [Notification.Kind.favourite, .reblog, .follow]
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct AdvancedPrefsView : View {
|
||||||
List {
|
List {
|
||||||
formattingSection
|
formattingSection
|
||||||
automationSection
|
automationSection
|
||||||
|
cachingSection
|
||||||
}.listStyle(GroupedListStyle())
|
}.listStyle(GroupedListStyle())
|
||||||
.navigationBarTitle(Text("Advanced"))
|
.navigationBarTitle(Text("Advanced"))
|
||||||
}
|
}
|
||||||
|
@ -41,6 +42,27 @@ struct AdvancedPrefsView : View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cachingSection: some View {
|
||||||
|
Section(header: Text("CACHING")) {
|
||||||
|
Button(action: clearCache) {
|
||||||
|
Text("Clear Cache")
|
||||||
|
}.foregroundColor(.red)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func clearCache() {
|
||||||
|
for account in LocalData.shared.accounts {
|
||||||
|
let controller = MastodonController.getForAccount(account)
|
||||||
|
let coordinator = controller.persistentContainer.persistentStoreCoordinator
|
||||||
|
for store in coordinator.persistentStores {
|
||||||
|
try! coordinator.destroyPersistentStore(at: store.url!, ofType: store.type, options: store.options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MastodonController.resetAll()
|
||||||
|
let mostRecent = LocalData.shared.getMostRecentAccount()!
|
||||||
|
NotificationCenter.default.post(name: .activateAccount, object: nil, userInfo: ["account": mostRecent])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension StatusContentType {
|
extension StatusContentType {
|
||||||
|
|
|
@ -62,8 +62,7 @@ class ProfileTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
if let id = accountID {
|
if let id = accountID, let container = mastodonController?.persistentContainer {
|
||||||
let container = mastodonController.persistentContainer
|
|
||||||
container.backgroundContext.perform {
|
container.backgroundContext.perform {
|
||||||
container.account(for: id, in: container.backgroundContext)?.decrementReferenceCount()
|
container.account(for: id, in: container.backgroundContext)?.decrementReferenceCount()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class StatusActionAccountListTableViewController: EnhancedTableViewController {
|
||||||
private let statusCell = "statusCell"
|
private let statusCell = "statusCell"
|
||||||
private let accountCell = "accountCell"
|
private let accountCell = "accountCell"
|
||||||
|
|
||||||
let mastodonController: MastodonController
|
weak var mastodonController: MastodonController!
|
||||||
|
|
||||||
let actionType: ActionType
|
let actionType: ActionType
|
||||||
let statusID: String
|
let statusID: String
|
||||||
|
@ -59,8 +59,7 @@ class StatusActionAccountListTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
if let accountIDs = self.accountIDs {
|
if let accountIDs = self.accountIDs, let container = mastodonController?.persistentContainer {
|
||||||
let container = self.mastodonController.persistentContainer
|
|
||||||
container.backgroundContext.perform {
|
container.backgroundContext.perform {
|
||||||
for id in accountIDs {
|
for id in accountIDs {
|
||||||
container.account(for: id, in: container.backgroundContext)?.decrementReferenceCount()
|
container.account(for: id, in: container.backgroundContext)?.decrementReferenceCount()
|
||||||
|
|
|
@ -39,12 +39,13 @@ class TimelineTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
guard let persistentContainer = mastodonController?.persistentContainer else { return }
|
||||||
// decrement reference counts of any statuses we still have
|
// decrement reference counts of any statuses we still have
|
||||||
// if the app is currently being quit, this will not affect the persisted data because
|
// if the app is currently being quit, this will not affect the persisted data because
|
||||||
// the persistent container would already have been saved in SceneDelegate.sceneDidEnterBackground(_:)
|
// the persistent container would already have been saved in SceneDelegate.sceneDidEnterBackground(_:)
|
||||||
for segment in timelineSegments {
|
for segment in timelineSegments {
|
||||||
for (id, _) in segment {
|
for (id, _) in segment {
|
||||||
mastodonController.persistentContainer.status(for: id)?.decrementReferenceCount()
|
persistentContainer.status(for: id)?.decrementReferenceCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue