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() {
|
public func suspend() {
|
||||||
delegate.cancelAll(for: self)
|
delegate.cancelAll(for: self)
|
||||||
|
delegate.suspend()
|
||||||
|
database.suspend()
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func resume() {
|
||||||
|
database.resume()
|
||||||
|
delegate.resume()
|
||||||
|
}
|
||||||
|
|
||||||
public func save() {
|
public func save() {
|
||||||
metadataFile.save()
|
metadataFile.save()
|
||||||
webFeedMetadataFile.save()
|
webFeedMetadataFile.save()
|
||||||
|
@ -51,4 +51,7 @@ protocol AccountDelegate {
|
|||||||
|
|
||||||
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?, completion: @escaping (Result<Credentials?, Error>) -> Void)
|
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() }
|
accounts.forEach { $0.suspend() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func resumeAll() {
|
||||||
|
accounts.forEach { $0.resume() }
|
||||||
|
}
|
||||||
|
|
||||||
public func refreshAll(errorHandler: @escaping (Error) -> Void, completion: (() ->Void)? = nil) {
|
public func refreshAll(errorHandler: @escaping (Error) -> Void, completion: (() ->Void)? = nil) {
|
||||||
let group = DispatchGroup()
|
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
|
// 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
|
// MARK: Private
|
||||||
|
@ -510,4 +510,16 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
|||||||
assertionFailure("An `account` instance should enqueue an \(FeedlyRefreshAccessTokenOperation.self) instead.")
|
assertionFailure("An `account` instance should enqueue an \(FeedlyRefreshAccessTokenOperation.self) instead.")
|
||||||
completion(.success(credentials))
|
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) {
|
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL? = nil, completion: (Result<Credentials?, Error>) -> Void) {
|
||||||
return completion(.success(nil))
|
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
|
// MARK: Private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user