Fix Swift strict concurrency warnings

This commit is contained in:
Thomas Ricouard 2024-01-26 13:01:23 +01:00
parent 096996c242
commit f16f0d514b
7 changed files with 10 additions and 11 deletions

View file

@ -9,12 +9,11 @@ import Notifications
import UIKit import UIKit
import UserNotifications import UserNotifications
@MainActor
class NotificationService: UNNotificationServiceExtension { class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)? var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent? var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { @MainActor override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
@ -124,6 +123,7 @@ class NotificationService: UNNotificationServiceExtension {
} }
} }
@MainActor
private func toRemoteNotification(localNotification: MastodonPushNotification) async -> Models.Notification? { private func toRemoteNotification(localNotification: MastodonPushNotification) async -> Models.Notification? {
do { do {
if let account = AppAccountsManager.shared.availableAccounts.first(where: { $0.oauthToken?.accessToken == localNotification.accessToken }) { if let account = AppAccountsManager.shared.availableAccounts.first(where: { $0.oauthToken?.accessToken == localNotification.accessToken }) {
@ -137,6 +137,7 @@ class NotificationService: UNNotificationServiceExtension {
return nil return nil
} }
@MainActor
private func buildMessageIntent(remoteNotification: Models.Notification, private func buildMessageIntent(remoteNotification: Models.Notification,
currentUser: String, currentUser: String,
avatarURL: URL) -> INSendMessageIntent avatarURL: URL) -> INSendMessageIntent

View file

@ -108,9 +108,7 @@ public struct ExploreView: View {
} }
} }
.task(id: viewModel.searchQuery) { .task(id: viewModel.searchQuery) {
do { await viewModel.search()
await viewModel.search()
} catch {}
} }
.onChange(of: scrollToTopSignal) { .onChange(of: scrollToTopSignal) {
if viewModel.scrollToTopVisible { if viewModel.scrollToTopVisible {

View file

@ -1,7 +1,7 @@
import Foundation import Foundation
import Models import Models
public struct DeepLClient { public struct DeepLClient: Sendable {
public enum DeepLError: Error { public enum DeepLError: Error {
case notFound case notFound
} }

View file

@ -1,7 +1,7 @@
import Foundation import Foundation
import Models import Models
public struct InstanceSocialClient { public struct InstanceSocialClient: Sendable {
private let authorization = "Bearer 8a4xx3D7Hzu1aFnf18qlkH8oU0oZ5ulabXxoS2FtQtwOy8G0DGQhr5PjTIjBnYAmFrSBuE2CcASjFocxJBonY8XGbLySB7MXd9ssrwlRHUXTQh3Z578lE1OfUtafvhML" private let authorization = "Bearer 8a4xx3D7Hzu1aFnf18qlkH8oU0oZ5ulabXxoS2FtQtwOy8G0DGQhr5PjTIjBnYAmFrSBuE2CcASjFocxJBonY8XGbLySB7MXd9ssrwlRHUXTQh3Z578lE1OfUtafvhML"
private let listEndpoint = "https://instances.social/api/1.0/instances/list?count=1000&include_closed=false&include_dead=false&min_active_users=500" private let listEndpoint = "https://instances.social/api/1.0/instances/list?count=1000&include_closed=false&include_dead=false&min_active_users=500"
private let searchEndpoint = "https://instances.social/api/1.0/instances/search" private let searchEndpoint = "https://instances.social/api/1.0/instances/search"

View file

@ -5,7 +5,7 @@ import SwiftUI
import UIKit import UIKit
extension StatusEditor { extension StatusEditor {
struct MediaContainer: Identifiable { struct MediaContainer: Identifiable, Sendable {
let id: String let id: String
let image: UIImage? let image: UIImage?
let movieTransferable: MovieFileTranseferable? let movieTransferable: MovieFileTranseferable?

View file

@ -72,7 +72,7 @@ extension StatusEditor {
} }
extension StatusEditor { extension StatusEditor {
final class MovieFileTranseferable: Transferable { final class MovieFileTranseferable: Transferable, Sendable {
let url: URL let url: URL
init(url: URL) { init(url: URL) {
@ -94,7 +94,7 @@ extension StatusEditor {
} }
} }
final class GifFileTranseferable: Transferable { final class GifFileTranseferable: Transferable, Sendable {
let url: URL let url: URL
init(url: URL) { init(url: URL) {

View file

@ -670,7 +670,7 @@ extension StatusEditor {
} }
} }
func makeMediaContainer(from pickerItem: PhotosPickerItem) async -> MediaContainer? { nonisolated func makeMediaContainer(from pickerItem: PhotosPickerItem) async -> MediaContainer? {
await withTaskGroup(of: MediaContainer?.self, returning: MediaContainer?.self) { taskGroup in await withTaskGroup(of: MediaContainer?.self, returning: MediaContainer?.self) { taskGroup in
taskGroup.addTask(priority: .high) { await Self.makeImageContainer(from: pickerItem) } taskGroup.addTask(priority: .high) { await Self.makeImageContainer(from: pickerItem) }
taskGroup.addTask(priority: .high) { await Self.makeGifContainer(from: pickerItem) } taskGroup.addTask(priority: .high) { await Self.makeGifContainer(from: pickerItem) }