Add AccountManager.resumeAll, Account.resume. Add suspend() and resume() to AccountDelegate and to individual AccountDelegate instances.
This commit is contained in:
parent
8ee169d915
commit
b5f1c69f8e
|
@ -407,9 +407,16 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
public func suspend() {
|
||||
delegate.cancelAll(for: self)
|
||||
delegate.suspend()
|
||||
database.suspend()
|
||||
save()
|
||||
}
|
||||
|
||||
public func resume() {
|
||||
database.resume()
|
||||
delegate.resume()
|
||||
}
|
||||
|
||||
public func save() {
|
||||
metadataFile.save()
|
||||
webFeedMetadataFile.save()
|
||||
|
|
|
@ -51,4 +51,7 @@ protocol AccountDelegate {
|
|||
|
||||
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?, completion: @escaping (Result<Credentials?, Error>) -> Void)
|
||||
|
||||
// For iOS, so we can suspend and resume properly.
|
||||
func suspend() // Make sure no SQLite databases are open.
|
||||
func resume()
|
||||
}
|
||||
|
|
|
@ -167,6 +167,10 @@ public final class AccountManager: UnreadCountProvider {
|
|||
accounts.forEach { $0.suspend() }
|
||||
}
|
||||
|
||||
public func resumeAll() {
|
||||
accounts.forEach { $0.resume() }
|
||||
}
|
||||
|
||||
public func refreshAll(errorHandler: @escaping (Error) -> Void, completion: (() ->Void)? = nil) {
|
||||
let group = DispatchGroup()
|
||||
|
||||
|
|
|
@ -438,6 +438,18 @@ final class FeedWranglerAccountDelegate: AccountDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Suspend and Resume (for iOS)
|
||||
|
||||
/// Suspend the sync database so that it can close its SQLite file.
|
||||
func suspend() {
|
||||
database.suspend()
|
||||
}
|
||||
|
||||
/// Resume the sync database — let it reopen its SQLite file.
|
||||
func resume() {
|
||||
database.resume()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
|
|
@ -556,6 +556,17 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
|||
|
||||
}
|
||||
|
||||
// MARK: Suspend and Resume (for iOS)
|
||||
|
||||
/// Suspend the sync database so that it can close its SQLite file.
|
||||
func suspend() {
|
||||
database.suspend()
|
||||
}
|
||||
|
||||
/// Resume the sync database — let it reopen its SQLite file.
|
||||
func resume() {
|
||||
database.resume()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
|
|
@ -510,4 +510,16 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
|||
assertionFailure("An `account` instance should enqueue an \(FeedlyRefreshAccessTokenOperation.self) instead.")
|
||||
completion(.success(credentials))
|
||||
}
|
||||
|
||||
// MARK: Suspend and Resume (for iOS)
|
||||
|
||||
/// Suspend the sync database so that it can close its SQLite file.
|
||||
func suspend() {
|
||||
database.suspend()
|
||||
}
|
||||
|
||||
/// Resume the sync database — let it reopen its SQLite file.
|
||||
func resume() {
|
||||
database.resume()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,4 +202,14 @@ final class LocalAccountDelegate: AccountDelegate {
|
|||
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL? = nil, completion: (Result<Credentials?, Error>) -> Void) {
|
||||
return completion(.success(nil))
|
||||
}
|
||||
|
||||
// MARK: Suspend and Resume (for iOS)
|
||||
|
||||
func suspend() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
func resume() {
|
||||
// Nothing to do
|
||||
}
|
||||
}
|
||||
|
|
|
@ -437,6 +437,17 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
|||
|
||||
}
|
||||
|
||||
// MARK: Suspend and Resume (for iOS)
|
||||
|
||||
/// Suspend the sync database so that it can close its SQLite file.
|
||||
func suspend() {
|
||||
database.suspend()
|
||||
}
|
||||
|
||||
/// Resume the sync database — let it reopen its SQLite file.
|
||||
func resume() {
|
||||
database.resume()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
|
Loading…
Reference in New Issue