forked from shadowfacts/Tusker
Fix a handful of strict concurrency warnings
This commit is contained in:
parent
216e58e5ec
commit
e94bee4fc8
@ -53,7 +53,7 @@ public struct PushSubscription {
|
||||
self.policy = policy
|
||||
}
|
||||
|
||||
public enum Policy: String, CaseIterable, Identifiable {
|
||||
public enum Policy: String, CaseIterable, Identifiable, Sendable {
|
||||
case all, followed, followers
|
||||
|
||||
public var id: some Hashable {
|
||||
@ -61,7 +61,7 @@ public struct PushSubscription {
|
||||
}
|
||||
}
|
||||
|
||||
public struct Alerts: OptionSet, Hashable {
|
||||
public struct Alerts: OptionSet, Hashable, Sendable {
|
||||
public static let mention = Alerts(rawValue: 1 << 0)
|
||||
public static let status = Alerts(rawValue: 1 << 1)
|
||||
public static let reblog = Alerts(rawValue: 1 << 2)
|
||||
|
@ -8,6 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
public struct Preferences {
|
||||
@MainActor
|
||||
public static let shared: PreferenceStore = load()
|
||||
|
||||
private static var documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
@ -18,6 +19,7 @@ public struct Preferences {
|
||||
|
||||
private init() {}
|
||||
|
||||
@MainActor
|
||||
public static func save() {
|
||||
let encoder = PropertyListEncoder()
|
||||
let data = try? encoder.encode(PreferenceCoding(wrapped: shared))
|
||||
|
@ -12,7 +12,7 @@ public enum PostVisibility: Codable, Hashable, CaseIterable, Sendable {
|
||||
case serverDefault
|
||||
case visibility(Visibility)
|
||||
|
||||
public static var allCases: [PostVisibility] = [.serverDefault] + Visibility.allCases.map { .visibility($0) }
|
||||
public private(set) static var allCases: [PostVisibility] = [.serverDefault] + Visibility.allCases.map { .visibility($0) }
|
||||
|
||||
public func resolved(withServerDefault serverDefault: Visibility?) -> Visibility {
|
||||
switch self {
|
||||
@ -57,7 +57,7 @@ public enum ReplyVisibility: Codable, Hashable, CaseIterable {
|
||||
case sameAsPost
|
||||
case visibility(Visibility)
|
||||
|
||||
public static var allCases: [ReplyVisibility] = [.sameAsPost] + Visibility.allCases.map { .visibility($0) }
|
||||
public private(set) static var allCases: [ReplyVisibility] = [.sameAsPost] + Visibility.allCases.map { .visibility($0) }
|
||||
|
||||
@MainActor
|
||||
public func resolved(withServerDefault serverDefault: Visibility?) -> Visibility {
|
||||
|
@ -8,7 +8,8 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
public class UserAccountsManager: ObservableObject {
|
||||
// Sendability: UserDefaults is not marked Sendable, but is documented as being thread safe
|
||||
public final class UserAccountsManager: ObservableObject, @unchecked Sendable {
|
||||
|
||||
public static let shared = UserAccountsManager()
|
||||
|
||||
|
@ -23,10 +23,10 @@ class LogoutService {
|
||||
|
||||
func run() {
|
||||
let accountInfo = self.accountInfo
|
||||
Task.detached {
|
||||
if await PushManager.shared.pushSubscription(account: accountInfo) != nil {
|
||||
Task.detached { @MainActor in
|
||||
if PushManager.shared.pushSubscription(account: accountInfo) != nil {
|
||||
_ = try? await self.mastodonController.run(Pachyderm.PushSubscription.delete())
|
||||
await PushManager.shared.removeSubscription(account: accountInfo)
|
||||
PushManager.shared.removeSubscription(account: accountInfo)
|
||||
}
|
||||
try? await self.mastodonController.client.revokeAccessToken()
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ struct FlipEffect: GeometryEffect {
|
||||
}
|
||||
|
||||
private struct WidthPrefKey: PreferenceKey {
|
||||
static var defaultValue: CGFloat = 0
|
||||
static let defaultValue: CGFloat = 0
|
||||
|
||||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
||||
value = nextValue()
|
||||
|
@ -292,7 +292,7 @@ private extension AttributeScopes {
|
||||
private enum HeadingLevelAttributes: CodableAttributedStringKey, MarkdownDecodableAttributedStringKey {
|
||||
public typealias Value = Int
|
||||
|
||||
public static var name = "headingLevel"
|
||||
public static let name = "headingLevel"
|
||||
}
|
||||
|
||||
private extension AttributeDynamicLookup {
|
||||
|
@ -59,7 +59,7 @@ struct ConfettiView: View {
|
||||
}
|
||||
|
||||
private struct SizeKey: PreferenceKey {
|
||||
static var defaultValue: CGSize = .zero
|
||||
static let defaultValue: CGSize = .zero
|
||||
static func reduce(value: inout CGSize, nextValue: () -> CGSize) {
|
||||
value = nextValue()
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ struct TipJarView: View {
|
||||
Text(error.localizedDescription)
|
||||
})
|
||||
.task {
|
||||
updatesObserver = Task.detached {
|
||||
updatesObserver = Task.detached { @MainActor in
|
||||
await observeTransactionUpdates()
|
||||
}
|
||||
do {
|
||||
@ -95,6 +95,7 @@ struct TipJarView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func observeTransactionUpdates() async {
|
||||
for await verificationResult in StoreKit.Transaction.updates {
|
||||
guard let index = products.firstIndex(where: { $0.0.id == verificationResult.unsafePayloadValue.productID }) else {
|
||||
@ -175,6 +176,7 @@ private struct TipRow: View {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func purchase() async {
|
||||
isPurchasing = true
|
||||
let result: Product.PurchaseResult
|
||||
@ -229,7 +231,7 @@ extension HorizontalAlignment {
|
||||
}
|
||||
|
||||
private struct ButtonWidthKey: PreferenceKey {
|
||||
static var defaultValue: CGFloat = 0
|
||||
static let defaultValue: CGFloat = 0
|
||||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
||||
value = max(value, nextValue())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user