Make sure metadata gets saved if background fetch is performed.

This commit is contained in:
Maurice Parker 2019-10-02 15:32:34 -05:00
parent af3e5e729c
commit 281416eaee
7 changed files with 15 additions and 8 deletions

View File

@ -368,10 +368,10 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
public func saveIfNecessary() {
metadataFile.saveIfNecessary()
feedMetadataFile.saveIfNecessary()
opmlFile.saveIfNecessary()
public func save() {
metadataFile.save()
feedMetadataFile.save()
opmlFile.save()
}
func loadOPMLItems(_ items: [RSOPMLItem], parentFolder: Folder?) {

View File

@ -184,6 +184,10 @@ public final class AccountManager: UnreadCountProvider {
}
}
public func saveAll() {
accounts.forEach { $0.save() }
}
public func anyAccountHasAtLeastOneFeed() -> Bool {
for account in activeAccounts {
if account.hasAtLeastOneFeed() {

View File

@ -31,7 +31,7 @@ final class AccountMetadataFile {
managedFile.load()
}
func saveIfNecessary() {
func save() {
managedFile.saveIfNecessary()
}

View File

@ -31,7 +31,7 @@ final class FeedMetadataFile {
managedFile.load()
}
func saveIfNecessary() {
func save() {
managedFile.saveIfNecessary()
}

View File

@ -32,7 +32,7 @@ final class OPMLFile {
managedFile.load()
}
func saveIfNecessary() {
func save() {
managedFile.saveIfNecessary()
}

View File

@ -298,6 +298,9 @@ private extension AppDelegate {
os_log("Account refresh operation completed.", log: self.log, type: .info)
task.setTaskCompleted(success: true)
}
AccountManager.shared.saveAll()
}
// set expiration handler

View File

@ -119,7 +119,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
switch result {
case .success:
account!.saveIfNecessary()
account!.save()
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
case .failure(let error):
self.presentError(error) {