Removes usage of for await notification handling

This removes the 70+ warnings
This commit is contained in:
Stuart Breckenridge
2023-04-07 19:03:33 +04:00
parent cc9780de99
commit a6fb6079c2
4 changed files with 24 additions and 39 deletions

View File

@@ -50,11 +50,9 @@ struct AddExtensionListView: View {
}
}
}
.task {
for await _ in NotificationCenter.default.notifications(named: .ActiveExtensionPointsDidChange) {
await MainActor.run(body: { dismiss() })
}
}
.onReceive(NotificationCenter.default.publisher(for: .ActiveExtensionPointsDidChange), perform: { _ in
dismiss()
})
}
}

View File

@@ -32,11 +32,9 @@ struct EnableExtensionPointView: View {
.navigationTitle(extensionPoint.title)
.navigationBarTitleDisplayMode(.inline)
.dismissOnExternalContextLaunch()
.task {
for await _ in NotificationCenter.default.notifications(named: .ActiveExtensionPointsDidChange) {
await MainActor.run { dismiss() }
}
}
.onReceive(NotificationCenter.default.publisher(for: .ActiveExtensionPointsDidChange), perform: { _ in
dismiss()
})
.edgesIgnoringSafeArea(.bottom)
}

View File

@@ -51,12 +51,9 @@ struct ExtensionsManagementView: View {
} message: {
Text("This action cannot be undone.", comment: "Alert message: confirmation that deactivation of extension cannot be undone.")
}
.task {
for await _ in NotificationCenter.default.notifications(named: .ActiveExtensionPointsDidChange) {
await MainActor.run { availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes.sorted(by: { $0.title < $1.title }) }
}
}
.onReceive(NotificationCenter.default.publisher(for: .ActiveExtensionPointsDidChange), perform: { _ in
availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes.sorted(by: { $0.title < $1.title })
})
}
private var activeExtensionsSection: some View {

View File

@@ -28,33 +28,25 @@ struct NewArticleNotificationsView: View, Logging {
}
.tint(Color(uiColor: AppAssets.primaryAccentColor))
.task {
for await notification in NotificationCenter.default.notifications(named: .FaviconDidBecomeAvailable) {
await MainActor.run {
guard let faviconURLString = notification.userInfo?["faviconURL"] as? String,
let faviconHost = URL(string: faviconURLString)?.host else {
return
}
activeAccounts.forEach { account in
for feed in Array(account.flattenedWebFeeds()) {
if let feedURLHost = URL(string: feed.url)?.host {
if faviconHost == feedURLHost {
feed.objectWillChange.send()
}
}
.onReceive(NotificationCenter.default.publisher(for: .FaviconDidBecomeAvailable), perform: { notification in
guard let faviconURLString = notification.userInfo?["faviconURL"] as? String,
let faviconHost = URL(string: faviconURLString)?.host else {
return
}
activeAccounts.forEach { account in
for feed in Array(account.flattenedWebFeeds()) {
if let feedURLHost = URL(string: feed.url)?.host {
if faviconHost == feedURLHost {
feed.objectWillChange.send()
}
}
}
}
}
.task {
for await notification in NotificationCenter.default.notifications(named: .WebFeedIconDidBecomeAvailable) {
await MainActor.run {
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? WebFeed else { return }
webFeed.objectWillChange.send()
}
}
}
})
.onReceive(NotificationCenter.default.publisher(for: .WebFeedIconDidBecomeAvailable), perform: { notification in
guard let webFeed = notification.userInfo?[UserInfoKey.webFeed] as? WebFeed else { return }
webFeed.objectWillChange.send()
})
}
private func sortedWebFeedsForAccount(_ account: Account) -> [WebFeed] {