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()
|
||||
|
|
|
@ -50,5 +50,8 @@ protocol AccountDelegate {
|
|||
func accountWillBeDeleted(_ account: Account)
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -166,7 +166,11 @@ public final class AccountManager: UnreadCountProvider {
|
|||
public func suspendAll() {
|
||||
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
|
||||
|
|
|
@ -555,7 +555,18 @@ 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -436,7 +436,18 @@ 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