Compare commits
No commits in common. "35a510e8ed31251d9d0d0003bbb42771f5cefe6f" and "e581f384e4ae8498ce7713f97429d9c74a97c2aa" have entirely different histories.
35a510e8ed
...
e581f384e4
|
@ -30,10 +30,6 @@ 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")!
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
let mastodonController: MastodonController
|
||||||
|
|
||||||
let mainStatusID: String
|
let mainStatusID: String
|
||||||
let mainStatusState: StatusState
|
let mainStatusState: StatusState
|
||||||
|
@ -43,9 +43,8 @@ class ConversationTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
guard let persistentContainer = mastodonController?.persistentContainer else { return }
|
|
||||||
for (id, _) in statuses {
|
for (id, _) in statuses {
|
||||||
persistentContainer.status(for: id)?.decrementReferenceCount()
|
mastodonController.persistentContainer.status(for: id)?.decrementReferenceCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Pachyderm
|
||||||
|
|
||||||
class ExploreViewController: EnhancedTableViewController {
|
class ExploreViewController: EnhancedTableViewController {
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
let 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"
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
let 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,7 +15,6 @@ struct AdvancedPrefsView : View {
|
||||||
List {
|
List {
|
||||||
formattingSection
|
formattingSection
|
||||||
automationSection
|
automationSection
|
||||||
cachingSection
|
|
||||||
}.listStyle(GroupedListStyle())
|
}.listStyle(GroupedListStyle())
|
||||||
.navigationBarTitle(Text("Advanced"))
|
.navigationBarTitle(Text("Advanced"))
|
||||||
}
|
}
|
||||||
|
@ -42,27 +41,6 @@ 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,7 +62,8 @@ class ProfileTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
if let id = accountID, let container = mastodonController?.persistentContainer {
|
if let id = accountID {
|
||||||
|
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"
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
let mastodonController: MastodonController
|
||||||
|
|
||||||
let actionType: ActionType
|
let actionType: ActionType
|
||||||
let statusID: String
|
let statusID: String
|
||||||
|
@ -59,7 +59,8 @@ class StatusActionAccountListTableViewController: EnhancedTableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
if let accountIDs = self.accountIDs, let container = mastodonController?.persistentContainer {
|
if let accountIDs = self.accountIDs {
|
||||||
|
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,13 +39,12 @@ 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 {
|
||||||
persistentContainer.status(for: id)?.decrementReferenceCount()
|
mastodonController.persistentContainer.status(for: id)?.decrementReferenceCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue