Convert receiveRemoteNotification to async/await.

This commit is contained in:
Brent Simmons 2024-03-26 20:49:47 -07:00
parent 402ee970cc
commit 887e35068e
8 changed files with 19 additions and 23 deletions

View File

@ -408,17 +408,9 @@ public enum FetchType {
grantingType.requestOAuthAccessToken(with: response, transport: transport, secretsProvider: secretsProvider, completion: completion)
}
private func receiveRemoteNotification(userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
delegate.receiveRemoteNotification(for: self, userInfo: userInfo, completion: completion)
}
public func receiveRemoteNotification(userInfo: [AnyHashable: Any]) async {
await withCheckedContinuation { continuation in
self.receiveRemoteNotification(userInfo: userInfo) {
continuation.resume()
}
}
await delegate.receiveRemoteNotification(for: self, userInfo: userInfo)
}
public func refreshAll() async throws {

View File

@ -23,7 +23,7 @@ import Secrets
var refreshProgress: DownloadProgress { get }
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void)
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async
func refreshAll(for account: Account) async throws
func syncArticleStatus(for account: Account) async throws

View File

@ -69,7 +69,16 @@ enum CloudKitAccountDelegateError: LocalizedError {
database = SyncDatabase(databasePath: databasePath)
}
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async {
await withCheckedContinuation { continuation in
self.receiveRemoteNotification(for: account, userInfo: userInfo) {
continuation.resume()
}
}
}
private func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
let op = CloudKitRemoteNotificationOperation(accountZone: accountZone, articlesZone: articlesZone, userInfo: userInfo)
op.completionBlock = { mainThreadOperaion in
completion()

View File

@ -75,8 +75,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
completion()
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async {
}
func refreshAll(for account: Account) async throws {

View File

@ -104,8 +104,7 @@ final class FeedlyAccountDelegate: AccountDelegate {
// MARK: Account API
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
completion()
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async {
}
func refreshAll(for account: Account) async throws {

View File

@ -40,8 +40,7 @@ final class LocalAccountDelegate: AccountDelegate {
let refreshProgress = DownloadProgress(numberOfTasks: 0)
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
completion()
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async {
}
func refreshAll(for account: Account) async throws {

View File

@ -57,10 +57,9 @@ final class NewsBlurAccountDelegate: AccountDelegate {
database = SyncDatabase(databasePath: dataFolder.appending("/DB.sqlite3"))
}
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
completion()
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async {
}
func refreshAll(for account: Account) async throws {
try await withCheckedThrowingContinuation { continuation in

View File

@ -101,10 +101,9 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
self.variant = variant
}
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) {
completion()
func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any]) async {
}
func refreshAll(for account: Account) async throws {
try await withCheckedThrowingContinuation { continuation in