mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Swift 6 Migration (#5733)
* Enable Swift 6.2 with default main actor isolation for the app target Turn on SWIFT_VERSION 6.2, SWIFT_APPROACHABLE_CONCURRENCY and SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor for the ElementX target, matching the NSE and Share Extension (which already use 6.2 without the main actor default). # Conflicts: # ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved * Update the code generation templates for Swift 6 Emit nonisolated/@unchecked Sendable mocks and nonisolated string enums, and mark async mock methods @concurrent so they keep suspending like the real implementations (otherwise intermediate states are unobservable in tests). Includes the regenerated mocks and strings. # Conflicts: # ElementX/Sources/Mocks/Generated/GeneratedMocks.swift * Make the data layer and services nonisolated and Sendable Annotate the value-type models, Rust SDK proxy wrappers, timeline item graph, settings, logging and NSE-shared types as nonisolated, and conform the service protocols to Sendable so their existentials can cross isolation boundaries. These types run off the main actor and no longer inherit the target's default main actor isolation. * Adopt the new isolation across call sites, mocks and signatures Update call sites, closure signatures and mock configuration helpers to match the nonisolated/Sendable data layer, including the main actor isolated mock inits and the @Sendable filter on recentlyVisitedRooms. ^ Conflicts: ^ ElementX/Sources/Services/SecureBackup/SecureBackupController.swift * Remove redundant @MainActor annotations With the app target defaulting to main actor isolation, the explicit @MainActor on view models, coordinators, views and their protocols is no longer required. * Fix concurrency hotspots surfaced by the migration Resolve the room summary main-thread deadlock by moving diff processing onto AsyncStreams, add the SDKListener.onMainActor FIFO bridge for SDK callbacks, hop KVO/timer/UIKit callbacks to the main actor via assumeIsolated, add isolated deinits, and apply the few justified nonisolated(unsafe) escapes for queue-confined Apple APIs. * Fix the unit tests for Swift 6 concurrency Hop the waitForConfirmation body onto the caller's actor (Swift Testing runs confirmation closures off-actor), and adjust the affected suites and async signatures. * offload diffs on concurrent threads instead of main actor * make room info protocols sendable * use a task group for fetching data so that everything runs concurrently in the TextRoomTimelineView when getting the preview. * use the generic onMainActor implementation, which already makes a stream and send the continuation on the main actor. * small pr comments issues being addressed * update enterprise * Update StaticCode to 1.1.0 and specify the required Swift isolation. * fix ElementCallServiceTests * update enterprise * re-generate mocks * update enterprise * enterprise new code conformed to swift 6 --------- Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -29,11 +29,11 @@ enum Avatars {
|
||||
}
|
||||
|
||||
/// Value in pixels by using the scale of the main screen
|
||||
var scaledValue: CGFloat {
|
||||
@MainActor var scaledValue: CGFloat {
|
||||
value * UIScreen.main.scale
|
||||
}
|
||||
|
||||
var scaledSize: CGSize {
|
||||
@MainActor var scaledSize: CGSize {
|
||||
CGSize(width: scaledValue, height: scaledValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum CallIntent: String, Codable, CaseIterable {
|
||||
nonisolated enum CallIntent: String, Codable, CaseIterable {
|
||||
case video, audio
|
||||
}
|
||||
|
||||
extension CallIntent {
|
||||
nonisolated extension CallIntent {
|
||||
// periphery:ignore - Unused, but added to detect new cases when updating the SDK.
|
||||
init(rustCallIntent: MatrixRustSDK.RtcCallIntent) {
|
||||
switch rustCallIntent {
|
||||
|
||||
@@ -12,7 +12,7 @@ import SwiftUI
|
||||
/// on the same row (moving them both to a new row if necessary).
|
||||
/// Each subview should be marked with the appropriate `ReactionLayoutItem` using the `reactionLayoutItem` modified
|
||||
/// so the layout can appropriately treat each type of item.
|
||||
struct CollapsibleReactionLayout: Layout {
|
||||
nonisolated struct CollapsibleReactionLayout: Layout {
|
||||
static let pointOffscreen = CGPoint(x: -10000, y: -10000)
|
||||
/// The horizontal spacing between items
|
||||
var itemSpacing: CGFloat = 0
|
||||
@@ -250,33 +250,33 @@ struct CollapsibleReactionLayout: Layout {
|
||||
}
|
||||
}
|
||||
|
||||
struct ReactionSubviews {
|
||||
nonisolated struct ReactionSubviews {
|
||||
var reactions: [FlowLayoutSubview]
|
||||
var collapseButton: FlowLayoutSubview
|
||||
var addMoreButton: FlowLayoutSubview
|
||||
}
|
||||
|
||||
/// A protocol representing subviews so that we can inject mocks in unit tests.
|
||||
protocol FlowLayoutSubviews: RandomAccessCollection where Element: FlowLayoutSubview, Index == Int, SubSequence == Self { }
|
||||
nonisolated protocol FlowLayoutSubviews: RandomAccessCollection where Element: FlowLayoutSubview, Index == Int, SubSequence == Self { }
|
||||
|
||||
extension LayoutSubviews: FlowLayoutSubviews { }
|
||||
nonisolated extension LayoutSubviews: FlowLayoutSubviews { }
|
||||
|
||||
/// A protocol representing a subview so that we can inject mocks in unit tests.
|
||||
protocol FlowLayoutSubview {
|
||||
nonisolated protocol FlowLayoutSubview {
|
||||
func sizeThatFits(_ proposal: ProposedViewSize) -> CGSize
|
||||
func place(at position: CGPoint, anchor: UnitPoint, proposal: ProposedViewSize)
|
||||
subscript<K>(key: K.Type) -> K.Value where K: LayoutValueKey { get }
|
||||
}
|
||||
|
||||
extension LayoutSubview: FlowLayoutSubview { }
|
||||
nonisolated extension LayoutSubview: FlowLayoutSubview { }
|
||||
|
||||
enum ReactionLayoutItem {
|
||||
nonisolated enum ReactionLayoutItem {
|
||||
case reaction
|
||||
case expandCollapse
|
||||
case addMore
|
||||
}
|
||||
|
||||
struct ReactionLayoutItemType: LayoutValueKey {
|
||||
nonisolated struct ReactionLayoutItemType: LayoutValueKey {
|
||||
static let defaultValue: ReactionLayoutItem = .reaction
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import Combine
|
||||
/// The purpose of this type is to remove the possibility to send new values on the underlying subject.
|
||||
///
|
||||
/// `CurrentValueSubject` is documented as thread-safe but is not formally `Sendable`, hence `@unchecked`.
|
||||
struct CurrentValuePublisher<Output, Failure: Error>: Publisher, @unchecked Sendable {
|
||||
nonisolated struct CurrentValuePublisher<Output, Failure: Error>: Publisher, @unchecked Sendable {
|
||||
private let subject: CurrentValueSubject<Output, Failure>
|
||||
|
||||
init(_ subject: CurrentValueSubject<Output, Failure>) {
|
||||
@@ -32,7 +32,7 @@ struct CurrentValuePublisher<Output, Failure: Error>: Publisher, @unchecked Send
|
||||
}
|
||||
}
|
||||
|
||||
extension CurrentValueSubject {
|
||||
nonisolated extension CurrentValueSubject {
|
||||
func asCurrentValuePublisher() -> CurrentValuePublisher<Output, Failure> {
|
||||
.init(self)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SceneKit
|
||||
import SwiftUI
|
||||
|
||||
class EffectsScene: SCNScene {
|
||||
nonisolated class EffectsScene: SCNScene {
|
||||
static let colors: [Color] = [
|
||||
.blue,
|
||||
.red,
|
||||
@@ -54,7 +54,7 @@ class EffectsScene: SCNScene {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Color {
|
||||
private nonisolated extension Color {
|
||||
/// The color's components as an array of floats in the extended linear sRGB colorspace.
|
||||
///
|
||||
/// SceneKit works in a colorspace with a linear gamma, which is why this conversion is necessary.
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
import AVKit
|
||||
import Foundation
|
||||
|
||||
enum AVMetadataBinaryValueError: Error {
|
||||
nonisolated enum AVMetadataBinaryValueError: Error {
|
||||
case unhandledQRSegmentMode(UInt8)
|
||||
case bitError(BitError)
|
||||
case unknown(Error)
|
||||
}
|
||||
|
||||
extension AVMetadataMachineReadableCodeObject {
|
||||
nonisolated extension AVMetadataMachineReadableCodeObject {
|
||||
var qrBinaryValue: Data? {
|
||||
get throws(AVMetadataBinaryValueError) {
|
||||
guard type == .qr else { return nil }
|
||||
@@ -66,11 +66,11 @@ enum BitError: Error {
|
||||
case unhandledAlphanumericCharacter(UInt8)
|
||||
}
|
||||
|
||||
private struct Bit {
|
||||
private nonisolated struct Bit {
|
||||
let value: UInt8
|
||||
}
|
||||
|
||||
private extension [Bit] {
|
||||
private nonisolated extension [Bit] {
|
||||
mutating func takeBits(_ count: Int) throws(BitError) -> UInt8 {
|
||||
guard count <= 8 else { throw .moreThan8BitsTaken }
|
||||
|
||||
@@ -163,7 +163,7 @@ private extension [Bit] {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Data {
|
||||
private nonisolated extension Data {
|
||||
func bits() -> [Bit] {
|
||||
var result = [Bit]()
|
||||
forEach { (byte: UInt8) in
|
||||
@@ -173,7 +173,7 @@ private extension Data {
|
||||
}
|
||||
}
|
||||
|
||||
private extension UInt8 {
|
||||
private nonisolated extension UInt8 {
|
||||
func bits() -> [Bit] {
|
||||
var bits: [Bit] = []
|
||||
for i in 0..<8 {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Array {
|
||||
nonisolated extension Array {
|
||||
func groupBy(_ isGroupable: (Element) -> Bool) -> [[Element]] {
|
||||
var newItems = [[Element]]()
|
||||
|
||||
@@ -60,7 +60,7 @@ extension Array {
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == RoomTimelineItemProtocol {
|
||||
nonisolated extension Array where Element == RoomTimelineItemProtocol {
|
||||
func firstUsingStableID(_ id: TimelineItemIdentifier) -> Element? {
|
||||
first { $0.id.uniqueID == id.uniqueID }
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
extension AsyncSequence {
|
||||
nonisolated extension AsyncSequence {
|
||||
func first() async rethrows -> Self.Element? {
|
||||
try await first { _ in true }
|
||||
var iterator = makeAsyncIterator()
|
||||
return try await iterator.next(isolation: #isolation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension AttributedString {
|
||||
nonisolated extension AttributedString {
|
||||
/// faster than doing `String(characters)`: https://forums.swift.org/t/attributedstring-to-string/61667
|
||||
var string: String {
|
||||
String(characters[...])
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import Synchronization
|
||||
|
||||
public extension Bundle {
|
||||
public nonisolated extension Bundle {
|
||||
/// The top-level bundle that contains the entire app.
|
||||
static var app: Bundle {
|
||||
var bundle = Bundle.main
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension CharacterSet {
|
||||
nonisolated extension CharacterSet {
|
||||
private static let urlAllowedSets: [CharacterSet] = [
|
||||
.urlUserAllowed,
|
||||
.urlPasswordAllowed,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
extension ClientBuilder {
|
||||
nonisolated extension ClientBuilder {
|
||||
/// A helper method that applies the common builder modifiers needed for the app.
|
||||
static func baseBuilder(setupEncryption: Bool = true,
|
||||
httpProxy: String? = nil,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Collection {
|
||||
nonisolated extension Collection {
|
||||
/// Returns the element at the specified index if it is within bounds, otherwise nil.
|
||||
subscript(safe index: Index) -> Element? {
|
||||
indices.contains(index) ? self[index] : nil
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
extension Date {
|
||||
/// The date formatted with the minimal necessary units given how long ago it occurred.
|
||||
func formattedMinimal() -> String {
|
||||
nonisolated func formattedMinimal() -> String {
|
||||
let calendar = Calendar.current
|
||||
|
||||
if calendar.isDateInToday(self) {
|
||||
@@ -35,7 +35,7 @@ extension Date {
|
||||
}
|
||||
|
||||
/// The date of an expiration formatted with the minimal necessary units given how long in the future it is.
|
||||
func formattedExpiration() -> String {
|
||||
nonisolated func formattedExpiration() -> String {
|
||||
let calendar = Calendar.current
|
||||
let now = Date.now
|
||||
|
||||
@@ -75,12 +75,12 @@ extension Date {
|
||||
}
|
||||
|
||||
/// The date formatted as just the time, for use in timeline items specifically.
|
||||
func formattedTime() -> String {
|
||||
nonisolated func formattedTime() -> String {
|
||||
formatted(date: .omitted, time: .shortened)
|
||||
}
|
||||
|
||||
/// A fixed date used for mocks, previews etc.
|
||||
static var mock: Date {
|
||||
nonisolated static var mock: Date {
|
||||
DateComponents(calendar: .current, year: 2007, month: 1, day: 9, hour: 9, minute: 41).date ?? .now
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Dictionary {
|
||||
nonisolated extension Dictionary {
|
||||
var jsonString: String? {
|
||||
guard let data = try? JSONSerialization.data(withJSONObject: self,
|
||||
options: [.fragmentsAllowed, .sortedKeys]) else {
|
||||
|
||||
@@ -12,7 +12,7 @@ enum FileManagerError: Error {
|
||||
case invalidFileSize
|
||||
}
|
||||
|
||||
extension FileManager {
|
||||
nonisolated extension FileManager {
|
||||
func directoryExists(at url: URL) -> Bool {
|
||||
var isDirectory: ObjCBool = false
|
||||
guard fileExists(atPath: url.path(percentEncoded: false), isDirectory: &isDirectory) else {
|
||||
|
||||
@@ -10,7 +10,6 @@ import Compound
|
||||
import HTMLParser
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
extension HTMLParserStyle {
|
||||
static let elementX = HTMLParserStyle(textColor: UIColor.label,
|
||||
linkColor: UIColor.link,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import Kingfisher
|
||||
|
||||
extension ImageCache {
|
||||
nonisolated extension ImageCache {
|
||||
static var onlyInMemory: ImageCache {
|
||||
let result = ImageCache.default
|
||||
result.memoryStorage.config.keepWhenEnteringBackground = true
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
/// NSRegularExpressions work internally on NSStrings, we need to be careful how we build the ranges for extended grapheme clusters https://stackoverflow.com/a/27880748/730924
|
||||
extension NSRegularExpression {
|
||||
nonisolated extension NSRegularExpression {
|
||||
func matches(in string: String, options: NSRegularExpression.MatchingOptions = []) -> [NSTextCheckingResult] {
|
||||
matches(in: string, options: options, range: .init(location: 0, length: (string as NSString).length))
|
||||
}
|
||||
|
||||
@@ -14,26 +14,34 @@ extension Observable {
|
||||
/// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0475-observed.md
|
||||
///
|
||||
/// - Parameter property: The key path to the property you would like to observe.
|
||||
func observe<Value>(_ property: KeyPath<Self, Value>) -> AsyncStream<Value> {
|
||||
AsyncStream { continuation in
|
||||
let isActive = Mutex(true)
|
||||
|
||||
@Sendable func observe() {
|
||||
@MainActor func observe<Value: Sendable>(_ property: KeyPath<Self, Value>) -> AsyncStream<Value> {
|
||||
let (stream, continuation) = AsyncStream<Value>.makeStream()
|
||||
let (changeSignals, changeSignaller) = AsyncStream<Void>.makeStream()
|
||||
|
||||
// Read and yield the initial value synchronously at subscription time,
|
||||
// otherwise observers miss changes made right after creating the stream.
|
||||
let initialValue = withObservationTracking {
|
||||
self[keyPath: property]
|
||||
} onChange: {
|
||||
changeSignaller.yield()
|
||||
}
|
||||
continuation.yield(initialValue)
|
||||
|
||||
let task = Task { @MainActor in
|
||||
// The signal is sent on willSet, but as this task runs on the next main
|
||||
// executor job the new value will have been set by the time we read it.
|
||||
for await _ in changeSignals {
|
||||
let value = withObservationTracking {
|
||||
self[keyPath: property]
|
||||
} onChange: {
|
||||
// Handle the update on the next run loop as this is willSet not didSet.
|
||||
DispatchQueue.main.async {
|
||||
guard isActive.withLock({ $0 }) else { return }
|
||||
observe()
|
||||
}
|
||||
changeSignaller.yield()
|
||||
}
|
||||
continuation.yield(value)
|
||||
}
|
||||
|
||||
continuation.onTermination = { _ in isActive.withLock { $0 = false } }
|
||||
|
||||
observe()
|
||||
}
|
||||
|
||||
continuation.onTermination = { _ in task.cancel() }
|
||||
|
||||
return stream
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension ProcessInfo {
|
||||
nonisolated extension ProcessInfo {
|
||||
/// Flag indicating whether the app is running the unit tests.
|
||||
static var isRunningUnitTests: Bool {
|
||||
#if DEBUG
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension ProposedViewSize: @retroactive Hashable {
|
||||
nonisolated extension ProposedViewSize: @retroactive Hashable {
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(width)
|
||||
hasher.combine(height)
|
||||
|
||||
@@ -46,8 +46,8 @@ extension Published.Publisher {
|
||||
var iterator = values.makeAsyncIterator()
|
||||
|
||||
// skips the publisher's current value
|
||||
_ = await iterator.next()
|
||||
return await iterator.next()
|
||||
_ = await iterator.next(isolation: #isolation)
|
||||
return await iterator.next(isolation: #isolation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
/// Returns the string as an `AttributedString` with the specified character tinted in a different color.
|
||||
/// - Parameters:
|
||||
/// - character: The character to be tinted.
|
||||
@@ -41,7 +41,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
func ellipsize(length: Int) -> String {
|
||||
guard count > length else {
|
||||
return self
|
||||
@@ -50,7 +50,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
func replacingHtmlBreaksOccurrences() -> String {
|
||||
var result = self
|
||||
let pattern = #"</p>(\n+)<p>"#
|
||||
@@ -74,14 +74,14 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
/// detects if the string is empty or contains only whitespaces and newlines
|
||||
var isBlank: Bool {
|
||||
trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
static func makeCanonicalAlias(aliasLocalPart: Self?, serverName: Self?) -> Self? {
|
||||
guard let aliasLocalPart, !aliasLocalPart.isEmpty,
|
||||
let serverName, !serverName.isEmpty else {
|
||||
@@ -91,7 +91,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
var validatedFileExtension: String {
|
||||
let fileExtension = (self as NSString).pathExtension
|
||||
guard !fileExtension.isEmpty else {
|
||||
@@ -101,7 +101,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
/// Whether the first character with a strong BiDi direction is right-to-left.
|
||||
/// Mirrors the Unicode BiDi "first strong" rule used by TextKit to resolve
|
||||
/// paragraph direction when `baseWritingDirection` is `.natural`.
|
||||
@@ -120,7 +120,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
/// To be used if the string is actually a URL
|
||||
var asSanitizedLink: String {
|
||||
var link = self
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import UserNotifications
|
||||
|
||||
extension UNNotificationContent {
|
||||
nonisolated extension UNNotificationContent {
|
||||
@objc var receiverID: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.receiverIdentifier] as? String
|
||||
}
|
||||
@@ -35,7 +35,7 @@ extension UNNotificationContent {
|
||||
}
|
||||
}
|
||||
|
||||
extension UNMutableNotificationContent {
|
||||
nonisolated extension UNMutableNotificationContent {
|
||||
override var receiverID: String? {
|
||||
get {
|
||||
userInfo[NotificationConstants.UserInfoKey.receiverIdentifier] as? String
|
||||
|
||||
@@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
// MARK: - Custom URLs
|
||||
|
||||
extension URL {
|
||||
nonisolated extension URL {
|
||||
/// The URL of the primary app group container.
|
||||
static var appGroupContainerDirectory: URL {
|
||||
guard let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: InfoPlistReader.main.appGroupIdentifier) else {
|
||||
@@ -135,34 +135,34 @@ extension URL {
|
||||
|
||||
// MARK: Mocks
|
||||
|
||||
static var mockMXCAudio: URL {
|
||||
nonisolated static var mockMXCAudio: URL {
|
||||
"mxc://matrix.org/1234567890AuDiO"
|
||||
}
|
||||
|
||||
static var mockMXCFile: URL {
|
||||
nonisolated static var mockMXCFile: URL {
|
||||
"mxc://matrix.org/1234567890FiLe"
|
||||
}
|
||||
|
||||
static var mockMXCImage: URL {
|
||||
nonisolated static var mockMXCImage: URL {
|
||||
"mxc://matrix.org/1234567890ImAgE"
|
||||
}
|
||||
|
||||
static var mockMXCVideo: URL {
|
||||
nonisolated static var mockMXCVideo: URL {
|
||||
"mxc://matrix.org/1234567890ViDeO"
|
||||
}
|
||||
|
||||
static var mockMXCAvatar: URL {
|
||||
nonisolated static var mockMXCAvatar: URL {
|
||||
"mxc://matrix.org/1234567890AvAtAr"
|
||||
}
|
||||
|
||||
static var mockMXCUserAvatar: URL {
|
||||
nonisolated static var mockMXCUserAvatar: URL {
|
||||
"mxc://matrix.org/1234567890AvAtArUsEr"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
extension URL: @retroactive ExpressibleByStringLiteral {
|
||||
nonisolated extension URL: @retroactive ExpressibleByStringLiteral {
|
||||
public init(stringLiteral value: StaticString) {
|
||||
guard let url = URL(string: "\(value)") else {
|
||||
fatalError("The static string used to create this URL is invalid")
|
||||
@@ -177,7 +177,7 @@ extension URL: @retroactive ExpressibleByStringLiteral {
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
nonisolated extension String {
|
||||
/// Assumes that the string is a URL and sanitises it for use as the name of a directory.
|
||||
func asURLDirectoryName() -> String {
|
||||
replacingOccurrences(of: "https://", with: "")
|
||||
@@ -188,7 +188,7 @@ extension String {
|
||||
|
||||
// MARK: - Phishing Confirmation URL
|
||||
|
||||
extension URL {
|
||||
nonisolated extension URL {
|
||||
static let confirmationScheme = "confirm"
|
||||
|
||||
var requiresConfirmation: Bool {
|
||||
@@ -204,7 +204,7 @@ extension URL {
|
||||
}
|
||||
}
|
||||
|
||||
struct ConfirmURLParameters {
|
||||
nonisolated struct ConfirmURLParameters {
|
||||
static let internalURLKey = "internalURL"
|
||||
static let displayStringKey = "displayString"
|
||||
|
||||
@@ -217,7 +217,7 @@ struct ConfirmURLParameters {
|
||||
}
|
||||
}
|
||||
|
||||
extension ConfirmURLParameters {
|
||||
nonisolated extension ConfirmURLParameters {
|
||||
init?(queryItems: [URLQueryItem]) {
|
||||
guard let internalURLString = queryItems.first(where: { $0.name == Self.internalURLKey })?.value,
|
||||
let internalURL = URL(string: internalURLString),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension URLSession {
|
||||
nonisolated extension URLSession {
|
||||
/// The same as `data(for:delegate:)` but with an additional immediate retry if the first attempt fails.
|
||||
func dataWithRetry(for request: URLRequest, delegate: URLSessionTaskDelegate? = nil) async throws -> (Data, URLResponse) {
|
||||
if let firstTryResult = try? await data(for: request, delegate: delegate) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
extension UTType {
|
||||
nonisolated extension UTType {
|
||||
/// Creates a type based on an optional mime type, falling back to a filename when this type is missing or unknown.
|
||||
init?(mimeType: String?, fallbackFilename: String) {
|
||||
guard let mimeType, let type = UTType(mimeType: mimeType) else {
|
||||
|
||||
@@ -13,7 +13,7 @@ import SwiftSoup
|
||||
import Synchronization
|
||||
import UIKit
|
||||
|
||||
protocol MentionBuilderProtocol {
|
||||
nonisolated protocol MentionBuilderProtocol: Sendable {
|
||||
func handleUserMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, userID: String, userDisplayName: String?)
|
||||
func handleRoomIDMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, roomID: String)
|
||||
func handleRoomAliasMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, roomAlias: String, roomDisplayName: String?)
|
||||
@@ -22,7 +22,7 @@ protocol MentionBuilderProtocol {
|
||||
func handleAllUsersMention(for attributedString: NSMutableAttributedString, in range: NSRange)
|
||||
}
|
||||
|
||||
extension NSAttributedString.Key {
|
||||
nonisolated extension NSAttributedString.Key {
|
||||
static let MatrixBlockquote: NSAttributedString.Key = .init(rawValue: BlockquoteAttribute.name)
|
||||
static let MatrixUserID: NSAttributedString.Key = .init(rawValue: UserIDAttribute.name)
|
||||
static let MatrixUserDisplayName: NSAttributedString.Key = .init(rawValue: UserDisplayNameAttribute.name)
|
||||
@@ -36,7 +36,7 @@ extension NSAttributedString.Key {
|
||||
static let InlineCode: NSAttributedString.Key = .init(rawValue: InlineCodeAttribute.name)
|
||||
}
|
||||
|
||||
struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
nonisolated struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
private static let defaultKey = "default"
|
||||
|
||||
private let cacheKey: String
|
||||
@@ -468,7 +468,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private struct TextParsingMatch {
|
||||
private nonisolated struct TextParsingMatch {
|
||||
enum MatchType {
|
||||
case userID(identifier: String)
|
||||
case roomAlias(alias: String)
|
||||
@@ -492,7 +492,7 @@ private struct TextParsingMatch {
|
||||
}
|
||||
}
|
||||
|
||||
private extension NSMutableAttributedString {
|
||||
private nonisolated extension NSMutableAttributedString {
|
||||
func setFontPreservingSymbolicTraits(_ newFont: UIFont) {
|
||||
enumerateAttribute(.font, in: NSRange(location: 0, length: length)) { value, range, _ in
|
||||
if let oldFont = value as? UIFont {
|
||||
@@ -512,7 +512,7 @@ private extension NSMutableAttributedString {
|
||||
}
|
||||
}
|
||||
|
||||
private extension NSString {
|
||||
private nonisolated extension NSString {
|
||||
func hasSuffixCharacter(from characterSet: CharacterSet) -> Bool {
|
||||
if length == 0 {
|
||||
return false
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct AttributedStringBuilderComponent: Hashable, Identifiable {
|
||||
nonisolated struct AttributedStringBuilderComponent: Hashable, Identifiable {
|
||||
enum ComponentType {
|
||||
case plainText
|
||||
case blockquote
|
||||
@@ -21,7 +21,7 @@ struct AttributedStringBuilderComponent: Hashable, Identifiable {
|
||||
let type: ComponentType
|
||||
}
|
||||
|
||||
protocol AttributedStringBuilderProtocol {
|
||||
nonisolated protocol AttributedStringBuilderProtocol: Sendable {
|
||||
func fromPlain(_ string: String?) -> AttributedString?
|
||||
|
||||
func fromHTML(_ htmlString: String?) -> AttributedString?
|
||||
|
||||
@@ -74,7 +74,7 @@ enum InlineCodeAttribute: AttributedStringKey {
|
||||
}
|
||||
|
||||
// periphery: ignore - required to make NSAttributedString to AttributedString conversion even if not used directly
|
||||
extension AttributeScopes {
|
||||
nonisolated extension AttributeScopes {
|
||||
struct ElementXAttributes: AttributeScope {
|
||||
let blockquote: BlockquoteAttribute
|
||||
|
||||
@@ -101,7 +101,7 @@ extension AttributeScopes {
|
||||
}
|
||||
|
||||
// periphery: ignore - required to make NSAttributedString to AttributedString conversion even if not used directly
|
||||
extension AttributeDynamicLookup {
|
||||
nonisolated extension AttributeDynamicLookup {
|
||||
subscript<T: AttributedStringKey>(dynamicMember keyPath: KeyPath<AttributeScopes.ElementXAttributes, T>) -> T {
|
||||
self[T.self]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
enum HTMLFixtures: String, CaseIterable {
|
||||
nonisolated enum HTMLFixtures: String, CaseIterable {
|
||||
case plainText
|
||||
case headers
|
||||
case paragraphs
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum PhishingDetector {
|
||||
nonisolated enum PhishingDetector {
|
||||
static func isPhishingAttempt(displayString: String, internalURL: URL) -> Bool {
|
||||
// Some phishing attempts can be hidden by using the unicode character "﹒" instead of "."
|
||||
let disambiguatedDisplayString = displayString.replacingOccurrences(of: "﹒", with: ".")
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct InfoPlistReader {
|
||||
nonisolated struct InfoPlistReader {
|
||||
private enum Keys {
|
||||
static let appGroupIdentifier = "appGroupIdentifier"
|
||||
static let baseBundleIdentifier = "baseBundleIdentifier"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum ExtensionLogger {
|
||||
nonisolated enum ExtensionLogger {
|
||||
/// Memory formatter, uses exact 2 fraction digits and no grouping
|
||||
private static var numberFormatter: NumberFormatter {
|
||||
let formatter = NumberFormatter()
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum LogLevel: String, Codable, Hashable {
|
||||
nonisolated enum LogLevel: String, Codable, Hashable {
|
||||
case error, warn, info, debug, trace
|
||||
|
||||
var title: String {
|
||||
|
||||
@@ -12,7 +12,7 @@ import MatrixRustSDK
|
||||
|
||||
/// Logging utility that provies multiple logging levels as well as file output and rolling.
|
||||
/// Its purpose is to provide a common entry for customizing logging and should be used throughout the code.
|
||||
enum MXLog {
|
||||
nonisolated enum MXLog {
|
||||
private nonisolated(unsafe) static var rootSpan: Span!
|
||||
private nonisolated(unsafe) static var currentTarget: String!
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum TraceLogPack: Codable, CaseIterable {
|
||||
nonisolated enum TraceLogPack: Codable, CaseIterable {
|
||||
case eventCache, sendQueue, timeline, notificationClient, syncProfiling, latestEvents
|
||||
|
||||
var title: String {
|
||||
@@ -24,7 +24,7 @@ enum TraceLogPack: Codable, CaseIterable {
|
||||
}
|
||||
}
|
||||
|
||||
extension TraceLogPack {
|
||||
nonisolated extension TraceLogPack {
|
||||
// periphery:ignore - Unused, but added to detect new cases when updating the SDK.
|
||||
init(rustLogPack: MatrixRustSDK.TraceLogPacks) {
|
||||
switch rustLogPack {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum Tracing {
|
||||
nonisolated enum Tracing {
|
||||
/// The directory that stores all of the log files.
|
||||
static var logsDirectory: URL {
|
||||
if ProcessInfo.isRunningIntegrationTests {
|
||||
|
||||
@@ -233,7 +233,10 @@ extension MapLibreMapView {
|
||||
|
||||
// Mirror every animated coordinate update to keep the camera as smooth as the marker.
|
||||
followedAnnotationObservation = annotation.observe(\.coordinate) { [weak mapView] annotation, _ in
|
||||
mapView?.setCenter(annotation.coordinate, animated: false)
|
||||
// The coordinate is only ever updated by SwiftUI so KVO fires on the main actor.
|
||||
MainActor.assumeIsolated {
|
||||
mapView?.setCenter(annotation.coordinate, animated: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,7 +306,7 @@ extension MapLibreMapView {
|
||||
// is an option set and gestures can come combined with other reasons, so check for
|
||||
// containment instead of an exact match.
|
||||
let centerChangingGestures: MLNCameraChangeReason = [.gesturePan, .gesturePinch, .gestureRotate]
|
||||
if !reason.intersection(centerChangingGestures).isEmpty {
|
||||
if !reason.isDisjoint(with: centerChangingGestures) {
|
||||
// Stop following immediately, the camera would fight the gesture otherwise.
|
||||
stopFollowingMarker()
|
||||
mapLibreView.userDidPan?()
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
/// https://spec.matrix.org/latest/appendices/#identifier-grammar
|
||||
enum MatrixEntityRegex: String {
|
||||
nonisolated enum MatrixEntityRegex: String {
|
||||
case homeserver
|
||||
case userID
|
||||
case roomAlias
|
||||
|
||||
@@ -11,7 +11,7 @@ enum PaginationDirection: String {
|
||||
case backwards, forwards
|
||||
}
|
||||
|
||||
enum PaginationState {
|
||||
nonisolated enum PaginationState {
|
||||
case idle
|
||||
case endReached
|
||||
case paginating
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
struct MentionBuilder: MentionBuilderProtocol {
|
||||
nonisolated struct MentionBuilder: MentionBuilderProtocol {
|
||||
struct AttributesToRestore {
|
||||
let font: UIFont
|
||||
let blockquote: Bool?
|
||||
@@ -173,7 +173,7 @@ struct MentionBuilder: MentionBuilderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Dictionary where Key == NSAttributedString.Key, Value == Any {
|
||||
private nonisolated extension Dictionary where Key == NSAttributedString.Key, Value == Any {
|
||||
mutating func addBlockquoteIfNeeded(_ value: Bool?) {
|
||||
if let value {
|
||||
self[.MatrixBlockquote] = value
|
||||
|
||||
@@ -59,7 +59,7 @@ final class MessageTextView: UITextView, PillAttachmentViewProviderDelegate, UIG
|
||||
/// as an invisible spacer so a message bubble's text reserves room for the overlaid
|
||||
/// timestamp. Without this subclass, an attachment with no image would render TextKit's
|
||||
/// default "missing image" glyph.
|
||||
private final class TransparentTextAttachment: NSTextAttachment {
|
||||
private final nonisolated class TransparentTextAttachment: NSTextAttachment {
|
||||
override func image(forBounds imageBounds: CGRect,
|
||||
textContainer: NSTextContainer?,
|
||||
characterIndex charIndex: Int) -> UIImage? {
|
||||
|
||||
@@ -23,44 +23,53 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider, NSSecureCo
|
||||
|
||||
// MARK: - Override
|
||||
|
||||
override init(textAttachment: NSTextAttachment, parentView: UIView?, textLayoutManager: NSTextLayoutManager?, location: NSTextLocation) {
|
||||
override nonisolated init(textAttachment: NSTextAttachment, parentView: UIView?, textLayoutManager: NSTextLayoutManager?, location: NSTextLocation) {
|
||||
super.init(textAttachment: textAttachment, parentView: parentView, textLayoutManager: textLayoutManager, location: location)
|
||||
|
||||
// Keep a reference to the parent text view for size adjustments and pills flushing.
|
||||
delegate = parentView?.superview as? PillAttachmentViewProviderDelegate
|
||||
// TextKit isn't annotated but creates the view providers on the main thread,
|
||||
// the assumeIsolated below would trap otherwise.
|
||||
nonisolated(unsafe) let provider = self
|
||||
MainActor.assumeIsolated {
|
||||
// Keep a reference to the parent text view for size adjustments and pills flushing.
|
||||
provider.delegate = parentView?.superview as? PillAttachmentViewProviderDelegate
|
||||
}
|
||||
tracksTextAttachmentViewBounds = true
|
||||
}
|
||||
|
||||
@MainActor
|
||||
override func loadView() {
|
||||
override nonisolated func loadView() {
|
||||
super.loadView()
|
||||
|
||||
guard let textAttachment = textAttachment as? PillTextAttachment,
|
||||
let pillData = textAttachment.pillData else {
|
||||
MXLog.failure("Attachment is missing data or not of expected class")
|
||||
return
|
||||
// TextKit isn't annotated but loads the view on the main thread,
|
||||
// the assumeIsolated below would trap otherwise.
|
||||
nonisolated(unsafe) let provider = self
|
||||
MainActor.assumeIsolated {
|
||||
guard let textAttachment = provider.textAttachment as? PillTextAttachment,
|
||||
let pillData = textAttachment.pillData else {
|
||||
MXLog.failure("Attachment is missing data or not of expected class")
|
||||
return
|
||||
}
|
||||
|
||||
let context: PillContext
|
||||
if ProcessInfo.isXcodePreview || ProcessInfo.isRunningTests {
|
||||
// The mock viewModel simulates the loading logic for testing purposes
|
||||
context = PillContext.mock(viewState: .mention(isOwnMention: false, displayText: "Alice"), delay: .seconds(2))
|
||||
} else if let timelineContext = provider.delegate?.timelineContext {
|
||||
context = PillContext(timelineContext: timelineContext, data: pillData)
|
||||
} else {
|
||||
MXLog.failure("Missing room context")
|
||||
return
|
||||
}
|
||||
|
||||
let view = PillView(context: context) { [weak provider] in
|
||||
provider?.delegate?.invalidateTextAttachmentsDisplay()
|
||||
}
|
||||
let controller = UIHostingController(rootView: view)
|
||||
controller.view.backgroundColor = .clear
|
||||
// This allows the text view to handle it as a link
|
||||
controller.view.isUserInteractionEnabled = false
|
||||
provider.view = controller.view
|
||||
provider.delegate?.registerPillView(controller.view)
|
||||
}
|
||||
|
||||
let context: PillContext
|
||||
if ProcessInfo.isXcodePreview || ProcessInfo.isRunningTests {
|
||||
// The mock viewModel simulates the loading logic for testing purposes
|
||||
context = PillContext.mock(viewState: .mention(isOwnMention: false, displayText: "Alice"), delay: .seconds(2))
|
||||
} else if let timelineContext = delegate?.timelineContext {
|
||||
context = PillContext(timelineContext: timelineContext, data: pillData)
|
||||
} else {
|
||||
MXLog.failure("Missing room context")
|
||||
return
|
||||
}
|
||||
|
||||
let view = PillView(context: context) { [weak self] in
|
||||
self?.delegate?.invalidateTextAttachmentsDisplay()
|
||||
}
|
||||
let controller = UIHostingController(rootView: view)
|
||||
controller.view.backgroundColor = .clear
|
||||
// This allows the text view to handle it as a link
|
||||
controller.view.isUserInteractionEnabled = false
|
||||
self.view = controller.view
|
||||
delegate?.registerPillView(controller.view)
|
||||
}
|
||||
|
||||
// MARK: - NSSecureCoding
|
||||
@@ -87,7 +96,6 @@ final class ComposerMentionDisplayHelper: MentionDisplayHelper {
|
||||
self.timelineContext = timelineContext
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static var mock: Self {
|
||||
Self(timelineContext: TimelineViewModel.mock.context)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
final class PillContext: ObservableObject {
|
||||
@Published var viewState: PillViewState = .undefined
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import UIKit
|
||||
|
||||
/// Text attachment for pills display.
|
||||
final class PillTextAttachment: NSTextAttachment {
|
||||
final nonisolated class PillTextAttachment: NSTextAttachment {
|
||||
convenience init?(attachmentData: PillTextAttachmentData) {
|
||||
let encoder = JSONEncoder()
|
||||
guard let encodedData = try? encoder.encode(attachmentData) else { return nil }
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
enum PillType: Codable, Equatable {
|
||||
nonisolated enum PillType: Codable, Equatable {
|
||||
enum EventRoom: Codable, Equatable {
|
||||
case roomAlias(String)
|
||||
case roomID(String)
|
||||
@@ -24,7 +24,7 @@ enum PillType: Codable, Equatable {
|
||||
case allUsers
|
||||
}
|
||||
|
||||
struct PillTextAttachmentData: Codable, Equatable {
|
||||
nonisolated struct PillTextAttachmentData: Codable, Equatable {
|
||||
struct Font: Codable, Equatable {
|
||||
let descender: CGFloat
|
||||
let lineHeight: CGFloat
|
||||
@@ -37,7 +37,7 @@ struct PillTextAttachmentData: Codable, Equatable {
|
||||
let fontData: Font
|
||||
}
|
||||
|
||||
extension PillTextAttachmentData {
|
||||
nonisolated extension PillTextAttachmentData {
|
||||
init(type: PillType, font: UIFont) {
|
||||
self.type = type
|
||||
fontData = Font(descender: font.descender, lineHeight: font.lineHeight)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum PillUtilities {
|
||||
nonisolated enum PillUtilities {
|
||||
static let atRoom = "@room"
|
||||
|
||||
/// Used by the WYSIWYG as the urlString value to identify @room mentions
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
/// In the future we might use this to do some customisation in what is plain text used to represent mentions.
|
||||
struct PlainMentionBuilder: MentionBuilderProtocol {
|
||||
nonisolated struct PlainMentionBuilder: MentionBuilderProtocol {
|
||||
func handleEventOnRoomAliasMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, eventID: String, roomAlias: String) { }
|
||||
|
||||
func handleEventOnRoomIDMention(for attributedString: NSMutableAttributedString, in range: NSRange, url: URL, eventID: String, roomID: String) { }
|
||||
|
||||
@@ -13,7 +13,7 @@ import MatrixRustSDK
|
||||
///
|
||||
/// To use this you'll need to add a conformance to the required listener
|
||||
/// protocol with a specialisation for the type it listens for.
|
||||
final class SDKListener<T>: Sendable {
|
||||
final nonisolated class SDKListener<T>: Sendable {
|
||||
private let onUpdateClosure: @Sendable (T) -> Void
|
||||
|
||||
/// Creates a new listener.
|
||||
@@ -23,21 +23,62 @@ final class SDKListener<T>: Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated extension SDKListener where T: Sendable {
|
||||
/// Creates a new listener that delivers its updates on the main actor in FIFO order,
|
||||
/// guaranteeing one in-flight update at a time.
|
||||
///
|
||||
/// The SDK calls listeners from arbitrary threads, use this whenever the updates
|
||||
/// need to touch main actor state. The internal stream (and so the long-lived task
|
||||
/// consuming it) ends when the listener is released.
|
||||
/// - Parameter onUpdate: A closure that will be called on the main actor whenever a new value is available.
|
||||
static func onMainActor(_ onUpdate: @escaping @MainActor (T) -> Void) -> SDKListener<T> {
|
||||
let (stream, continuation) = AsyncStream<T>.makeStream()
|
||||
|
||||
Task { @MainActor in
|
||||
for await value in stream {
|
||||
onUpdate(value)
|
||||
}
|
||||
}
|
||||
|
||||
// The wrapper is owned by the listener's closure, so when the SDK releases the listener
|
||||
// (its subscription handle being dropped) the wrapper deinits and finishes the stream,
|
||||
// ending the consumer task above. Deiniting the continuation alone does *not* terminate
|
||||
// the stream (see SE-0406), which would otherwise leak the task.
|
||||
let continuationWrapper = StreamContinuationWrapper(continuation)
|
||||
return SDKListener { value in
|
||||
continuationWrapper.continuation.yield(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Owns an `AsyncStream.Continuation` and finishes its stream when released.
|
||||
private final nonisolated class StreamContinuationWrapper<Element: Sendable>: Sendable {
|
||||
let continuation: AsyncStream<Element>.Continuation
|
||||
|
||||
init(_ continuation: AsyncStream<Element>.Continuation) {
|
||||
self.continuation = continuation
|
||||
}
|
||||
|
||||
deinit {
|
||||
continuation.finish()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: QRCodeLoginService
|
||||
|
||||
extension SDKListener: QrLoginProgressListener where T == QrLoginProgress {
|
||||
nonisolated extension SDKListener: QrLoginProgressListener where T == QrLoginProgress {
|
||||
func onUpdate(state: QrLoginProgress) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: GrantQrLoginProgressListener where T == GrantQrLoginProgress {
|
||||
nonisolated extension SDKListener: GrantQrLoginProgressListener where T == GrantQrLoginProgress {
|
||||
func onUpdate(state: GrantQrLoginProgress) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: GrantGeneratedQrLoginProgressListener where T == GrantGeneratedQrLoginProgress {
|
||||
nonisolated extension SDKListener: GrantGeneratedQrLoginProgressListener where T == GrantGeneratedQrLoginProgress {
|
||||
func onUpdate(state: GrantGeneratedQrLoginProgress) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
@@ -45,49 +86,49 @@ extension SDKListener: GrantGeneratedQrLoginProgressListener where T == GrantGen
|
||||
|
||||
// MARK: ClientProxy
|
||||
|
||||
extension SDKListener: MediaPreviewConfigListener where T == MediaPreviewConfig? {
|
||||
nonisolated extension SDKListener: MediaPreviewConfigListener where T == MediaPreviewConfig? {
|
||||
func onChange(mediaPreviewConfig: MediaPreviewConfig?) {
|
||||
onUpdateClosure(mediaPreviewConfig)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SyncServiceStateObserver where T == SyncServiceState {
|
||||
nonisolated extension SDKListener: SyncServiceStateObserver where T == SyncServiceState {
|
||||
func onUpdate(state: SyncServiceState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RoomListServiceStateListener where T == RoomListServiceState {
|
||||
nonisolated extension SDKListener: RoomListServiceStateListener where T == RoomListServiceState {
|
||||
func onUpdate(state: RoomListServiceState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RoomListServiceSyncIndicatorListener where T == RoomListServiceSyncIndicator {
|
||||
nonisolated extension SDKListener: RoomListServiceSyncIndicatorListener where T == RoomListServiceSyncIndicator {
|
||||
func onUpdate(syncIndicator: RoomListServiceSyncIndicator) {
|
||||
onUpdateClosure(syncIndicator)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: VerificationStateListener where T == VerificationState {
|
||||
nonisolated extension SDKListener: VerificationStateListener where T == VerificationState {
|
||||
func onUpdate(status: VerificationState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: IgnoredUsersListener where T == [String] {
|
||||
nonisolated extension SDKListener: IgnoredUsersListener where T == [String] {
|
||||
func call(ignoredUserIds: [String]) {
|
||||
onUpdateClosure(ignoredUserIds)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SendQueueRoomErrorListener where T == (String, ClientError) {
|
||||
nonisolated extension SDKListener: SendQueueRoomErrorListener where T == (String, ClientError) {
|
||||
func onError(roomId: String, error: ClientError) {
|
||||
onUpdateClosure((roomId, error))
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SendQueueRoomUpdateListener where T == (String, RoomSendQueueUpdate) {
|
||||
nonisolated extension SDKListener: SendQueueRoomUpdateListener where T == (String, RoomSendQueueUpdate) {
|
||||
func onUpdate(roomId: String, update: RoomSendQueueUpdate) {
|
||||
onUpdateClosure((roomId, update))
|
||||
}
|
||||
@@ -95,25 +136,25 @@ extension SDKListener: SendQueueRoomUpdateListener where T == (String, RoomSendQ
|
||||
|
||||
// MARK: SecureBackupController
|
||||
|
||||
extension SDKListener: BackupStateListener where T == BackupState {
|
||||
nonisolated extension SDKListener: BackupStateListener where T == BackupState {
|
||||
func onUpdate(status: BackupState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RecoveryStateListener where T == RecoveryState {
|
||||
nonisolated extension SDKListener: RecoveryStateListener where T == RecoveryState {
|
||||
func onUpdate(status: RecoveryState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: EnableRecoveryProgressListener where T == EnableRecoveryProgress {
|
||||
nonisolated extension SDKListener: EnableRecoveryProgressListener where T == EnableRecoveryProgress {
|
||||
func onUpdate(status: EnableRecoveryProgress) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: BackupSteadyStateListener where T == BackupUploadState {
|
||||
nonisolated extension SDKListener: BackupSteadyStateListener where T == BackupUploadState {
|
||||
func onUpdate(status: BackupUploadState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
@@ -121,13 +162,13 @@ extension SDKListener: BackupSteadyStateListener where T == BackupUploadState {
|
||||
|
||||
// MARK: RoomSummaryProvider
|
||||
|
||||
extension SDKListener: RoomListEntriesListener where T == [RoomListEntriesUpdate] {
|
||||
nonisolated extension SDKListener: RoomListEntriesListener where T == [RoomListEntriesUpdate] {
|
||||
func onUpdate(roomEntriesUpdate: [RoomListEntriesUpdate]) {
|
||||
onUpdateClosure(roomEntriesUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: RoomListLoadingStateListener where T == RoomListLoadingState {
|
||||
nonisolated extension SDKListener: RoomListLoadingStateListener where T == RoomListLoadingState {
|
||||
func onUpdate(state: RoomListLoadingState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
@@ -135,31 +176,31 @@ extension SDKListener: RoomListLoadingStateListener where T == RoomListLoadingSt
|
||||
|
||||
// MARK: Spaces
|
||||
|
||||
extension SDKListener: SpaceServiceJoinedSpacesListener where T == [SpaceListUpdate] {
|
||||
nonisolated extension SDKListener: SpaceServiceJoinedSpacesListener where T == [SpaceListUpdate] {
|
||||
func onUpdate(rooms: [SpaceListUpdate]) {
|
||||
onUpdateClosure(rooms)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceRoomListEntriesListener where T == [SpaceListUpdate] {
|
||||
nonisolated extension SDKListener: SpaceRoomListEntriesListener where T == [SpaceListUpdate] {
|
||||
func onUpdate(roomUpdates: [SpaceListUpdate]) {
|
||||
onUpdateClosure(roomUpdates)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceRoomListPaginationStateListener where T == SpaceRoomListPaginationState {
|
||||
nonisolated extension SDKListener: SpaceRoomListPaginationStateListener where T == SpaceRoomListPaginationState {
|
||||
func onUpdate(paginationState: SpaceRoomListPaginationState) {
|
||||
onUpdateClosure(paginationState)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceRoomListSpaceListener where T == SpaceRoom? {
|
||||
nonisolated extension SDKListener: SpaceRoomListSpaceListener where T == SpaceRoom? {
|
||||
func onUpdate(space: SpaceRoom?) {
|
||||
onUpdateClosure(space)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: SpaceServiceSpaceFiltersListener where T == [SpaceFilterUpdate] {
|
||||
nonisolated extension SDKListener: SpaceServiceSpaceFiltersListener where T == [SpaceFilterUpdate] {
|
||||
func onUpdate(filterUpdates: [SpaceFilterUpdate]) {
|
||||
onUpdateClosure(filterUpdates)
|
||||
}
|
||||
@@ -167,55 +208,55 @@ extension SDKListener: SpaceServiceSpaceFiltersListener where T == [SpaceFilterU
|
||||
|
||||
// MARK: Room
|
||||
|
||||
extension SDKListener: RoomInfoListener where T == RoomInfo {
|
||||
nonisolated extension SDKListener: RoomInfoListener where T == RoomInfo {
|
||||
func call(roomInfo: RoomInfo) {
|
||||
onUpdateClosure(roomInfo)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: CallDeclineListener where T == String {
|
||||
nonisolated extension SDKListener: CallDeclineListener where T == String {
|
||||
func call(declinerUserId: String) {
|
||||
onUpdateClosure(declinerUserId)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: TypingNotificationsListener where T == [String] {
|
||||
nonisolated extension SDKListener: TypingNotificationsListener where T == [String] {
|
||||
func call(typingUserIds: [String]) {
|
||||
onUpdateClosure(typingUserIds)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: IdentityStatusChangeListener where T == [IdentityStatusChange] {
|
||||
nonisolated extension SDKListener: IdentityStatusChangeListener where T == [IdentityStatusChange] {
|
||||
func call(identityStatusChange: [IdentityStatusChange]) {
|
||||
onUpdateClosure(identityStatusChange)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: KnockRequestsListener where T == [KnockRequest] {
|
||||
nonisolated extension SDKListener: KnockRequestsListener where T == [KnockRequest] {
|
||||
func call(joinRequests: [KnockRequest]) {
|
||||
onUpdateClosure(joinRequests)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: LiveLocationsListener where T == [LiveLocationShareUpdate] {
|
||||
nonisolated extension SDKListener: LiveLocationsListener where T == [LiveLocationShareUpdate] {
|
||||
func onUpdate(updates: [LiveLocationShareUpdate]) {
|
||||
onUpdateClosure(updates)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: BeaconInfoListener where T == BeaconInfoUpdate {
|
||||
nonisolated extension SDKListener: BeaconInfoListener where T == BeaconInfoUpdate {
|
||||
func onUpdate(update: BeaconInfoUpdate) {
|
||||
onUpdateClosure(update)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: ThreadListEntriesListener where T == [ThreadListUpdate] {
|
||||
nonisolated extension SDKListener: ThreadListEntriesListener where T == [ThreadListUpdate] {
|
||||
func onUpdate(diff: [ThreadListUpdate]) {
|
||||
onUpdateClosure(diff)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: ThreadListPaginationStateListener where T == ThreadListPaginationState {
|
||||
nonisolated extension SDKListener: ThreadListPaginationStateListener where T == ThreadListPaginationState {
|
||||
func onUpdate(state: ThreadListPaginationState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
@@ -223,13 +264,13 @@ extension SDKListener: ThreadListPaginationStateListener where T == ThreadListPa
|
||||
|
||||
// MARK: TimelineProxy
|
||||
|
||||
extension SDKListener: PaginationStatusListener where T == PaginationStatus {
|
||||
nonisolated extension SDKListener: PaginationStatusListener where T == PaginationStatus {
|
||||
func onUpdate(status: PaginationStatus) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
extension SDKListener: ProgressWatcher where T == Double {
|
||||
nonisolated extension SDKListener: ProgressWatcher where T == Double {
|
||||
func transmissionProgress(progress: TransmissionProgress) {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.onUpdateClosure(Double(progress.current) / Double(progress.total))
|
||||
@@ -239,7 +280,7 @@ extension SDKListener: ProgressWatcher where T == Double {
|
||||
|
||||
// MARK: TimelineItemProvider
|
||||
|
||||
extension SDKListener: TimelineListener where T == [TimelineDiff] {
|
||||
nonisolated extension SDKListener: TimelineListener where T == [TimelineDiff] {
|
||||
func onUpdate(diff: [TimelineDiff]) {
|
||||
onUpdateClosure(diff)
|
||||
}
|
||||
@@ -247,7 +288,7 @@ extension SDKListener: TimelineListener where T == [TimelineDiff] {
|
||||
|
||||
// MARK: RoomDirectorySearchProxy
|
||||
|
||||
extension SDKListener: RoomDirectorySearchEntriesListener where T == [RoomDirectorySearchEntryUpdate] {
|
||||
nonisolated extension SDKListener: RoomDirectorySearchEntriesListener where T == [RoomDirectorySearchEntryUpdate] {
|
||||
func onUpdate(roomEntriesUpdate: [RoomDirectorySearchEntryUpdate]) {
|
||||
onUpdateClosure(roomEntriesUpdate)
|
||||
}
|
||||
|
||||
@@ -27,30 +27,33 @@ final class ShareToMapsAppActivity: UIActivity {
|
||||
super.init()
|
||||
}
|
||||
|
||||
override private init() {
|
||||
override private nonisolated init() {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
override var activityTitle: String? {
|
||||
override nonisolated var activityTitle: String? {
|
||||
type.activityTitle
|
||||
}
|
||||
|
||||
override var activityType: UIActivity.ActivityType {
|
||||
override nonisolated var activityType: UIActivity.ActivityType {
|
||||
.shareToMapsApp
|
||||
}
|
||||
|
||||
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
|
||||
override nonisolated func canPerform(withActivityItems activityItems: [Any]) -> Bool {
|
||||
true
|
||||
}
|
||||
|
||||
override func prepare(withActivityItems activityItems: [Any]) {
|
||||
UIApplication.shared.open(type.activityURL(for: location, senderName: senderName), options: [:]) { [weak self] result in
|
||||
self?.activityDidFinish(result)
|
||||
override nonisolated func prepare(withActivityItems activityItems: [Any]) {
|
||||
// UIActivity isn't annotated but UIKit guarantees this is called on the main thread.
|
||||
MainActor.assumeIsolated {
|
||||
UIApplication.shared.open(type.activityURL(for: location, senderName: senderName), options: [:]) { [weak self] result in
|
||||
self?.activityDidFinish(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ShareToMapsAppActivity.MapsAppType {
|
||||
nonisolated extension ShareToMapsAppActivity.MapsAppType {
|
||||
func activityURL(for location: CLLocationCoordinate2D, senderName: String?) -> URL {
|
||||
switch self {
|
||||
case .apple:
|
||||
@@ -89,6 +92,6 @@ extension ShareToMapsAppActivity.MapsAppType {
|
||||
}
|
||||
}
|
||||
|
||||
private extension UIActivity.ActivityType {
|
||||
private nonisolated extension UIActivity.ActivityType {
|
||||
static let shareToMapsApp = UIActivity.ActivityType("ElementX.ShareToMapsApp")
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ struct FullscreenDialog<Content: View, BottomContent: View>: View {
|
||||
}
|
||||
|
||||
/// A layout where the content scrolls with the bottom content overlaid. Used with regular font sizes.
|
||||
@MainActor var standardLayout: some View {
|
||||
var standardLayout: some View {
|
||||
GeometryReader { geometry in
|
||||
ScrollView {
|
||||
VStack(spacing: 0) {
|
||||
|
||||
@@ -13,10 +13,9 @@ extension View {
|
||||
/// Reads the frame of the view and stores it in the `frame` binding.
|
||||
/// - Parameters:
|
||||
/// - frame: a `CGRect` binding
|
||||
/// - coordinateSpace: the coordinate space of the frame.
|
||||
func readFrame(_ frame: Binding<CGRect>, in coordinateSpace: CoordinateSpace = .local) -> some View {
|
||||
func readFrame(_ frame: Binding<CGRect>) -> some View {
|
||||
onGeometryChange(for: CGRect.self) { geometry in
|
||||
geometry.frame(in: coordinateSpace)
|
||||
geometry.frame(in: .local)
|
||||
} action: { newValue in
|
||||
frame.wrappedValue = newValue
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import Foundation
|
||||
|
||||
/// Represents a specific portion of the ViewState that can be bound to with SwiftUI's [2-way binding](https://developer.apple.com/documentation/swiftui/binding).
|
||||
@MainActor
|
||||
protocol BindableState {
|
||||
/// The associated type of the Bindable State. Defaults to Void.
|
||||
associatedtype BindStateType = Void
|
||||
|
||||
@@ -16,7 +16,6 @@ import Foundation
|
||||
/// a specific portion of state that can be safely bound to.
|
||||
/// If we decide to add more features to our state management (like doing state processing off the main thread)
|
||||
/// we can do it in this centralised place.
|
||||
@MainActor
|
||||
class StateStoreViewModel<State: BindableState, ViewAction> {
|
||||
/// For storing subscription references.
|
||||
///
|
||||
@@ -57,7 +56,6 @@ class StateStoreViewModel<State: BindableState, ViewAction> {
|
||||
/// It provides a nice layer of consistency and also safety. As we are not passing the `ViewModel` to the view directly, shortcuts/hacks
|
||||
/// can't be made into the `ViewModel`.
|
||||
@dynamicMemberLookup
|
||||
@MainActor
|
||||
final class Context: ObservableObject {
|
||||
fileprivate weak var viewModel: StateStoreViewModel?
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import Observation
|
||||
/// a specific portion of state that can be safely bound to.
|
||||
/// If we decide to add more features to our state management (like doing state processing off the main thread)
|
||||
/// we can do it in this centralised place.
|
||||
@MainActor
|
||||
class StateStoreViewModelV2<State: BindableState, ViewAction> {
|
||||
/// For storing subscription references.
|
||||
///
|
||||
@@ -59,7 +58,6 @@ class StateStoreViewModelV2<State: BindableState, ViewAction> {
|
||||
/// It provides a nice layer of consistency and also safety. As we are not passing the `ViewModel` to the view directly, shortcuts/hacks
|
||||
/// can't be made into the `ViewModel`.
|
||||
@dynamicMemberLookup
|
||||
@MainActor
|
||||
@Observable final class Context {
|
||||
fileprivate weak var viewModel: StateStoreViewModelV2?
|
||||
|
||||
|
||||
@@ -230,16 +230,24 @@ private struct LoadableImageContent<TransformerView: View, PlaceholderView: View
|
||||
|
||||
// MARK: - ImageDataProvider
|
||||
|
||||
var cacheKey: String {
|
||||
nonisolated var cacheKey: String {
|
||||
mediaSource.url.absoluteString
|
||||
}
|
||||
|
||||
func data(handler: @escaping (Result<Data, Error>) -> Void) {
|
||||
guard case let .gifData(data) = contentLoader.content else {
|
||||
nonisolated func data(handler: @escaping (Result<Data, Error>) -> Void) {
|
||||
// Kingfisher isn't annotated but invokes the provider on the main thread.
|
||||
let gifData = MainActor.assumeIsolated { () -> Data? in
|
||||
guard case let .gifData(data) = contentLoader.content else {
|
||||
return nil
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
guard let gifData else {
|
||||
fatalError("Shouldn't reach this point without any gif data")
|
||||
}
|
||||
|
||||
handler(.success(data))
|
||||
handler(.success(gifData))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +287,6 @@ private class ContentLoader: ObservableObject {
|
||||
self.mediaProvider = mediaProvider
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func load() async {
|
||||
if isGIF {
|
||||
if case let .success(data) = await mediaProvider?.loadImageDataFromSource(mediaSource) {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
struct RoomInviterDetails: Equatable {
|
||||
let id: String
|
||||
let displayName: String?
|
||||
|
||||
@@ -9,7 +9,6 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct ToolbarButton: View {
|
||||
@MainActor
|
||||
enum Role {
|
||||
static let cancel = Role.cancel(title: L10n.actionCancel)
|
||||
static let done = Role.confirm(title: L10n.actionDone)
|
||||
|
||||
@@ -13,7 +13,12 @@ import UIKit
|
||||
import DeviceKit
|
||||
#endif
|
||||
|
||||
enum UserAgentBuilder {
|
||||
nonisolated enum UserAgentBuilder {
|
||||
/// The screen scale used in the user agent. It never changes at runtime, so it's captured once
|
||||
/// on the main actor at launch (see the app coordinator) and read freely from any thread/process.
|
||||
/// Contexts without a screen (e.g. the NSE) keep the default.
|
||||
nonisolated(unsafe) static var displayScale: CGFloat = 2.0
|
||||
|
||||
static func makeASCIIUserAgent() -> String {
|
||||
makeUserAgent()?.asciified() ?? "unknown"
|
||||
}
|
||||
@@ -23,20 +28,21 @@ enum UserAgentBuilder {
|
||||
let clientVersion = InfoPlistReader.app.bundleShortVersionString
|
||||
|
||||
#if os(iOS)
|
||||
let scale = UIScreen.main.scale
|
||||
let osVersion = ProcessInfo.processInfo.operatingSystemVersion
|
||||
let systemVersion = "\(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)"
|
||||
return if ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
String(format: "%@/%@ (Mac; macOS %@; Scale/%0.2f)",
|
||||
clientName,
|
||||
clientVersion,
|
||||
ProcessInfo.processInfo.operatingSystemVersionString,
|
||||
scale)
|
||||
displayScale)
|
||||
} else {
|
||||
String(format: "%@/%@ (%@; iOS %@; Scale/%0.2f)",
|
||||
clientName,
|
||||
clientVersion,
|
||||
Device.current.safeDescription,
|
||||
UIDevice.current.systemVersion,
|
||||
scale)
|
||||
systemVersion,
|
||||
displayScale)
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
return String(format: "%@/%@ (%@; tvOS %@; Scale/%0.2f)",
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct EstimatedWaveform: Equatable, Hashable {
|
||||
nonisolated struct EstimatedWaveform: Equatable, Hashable {
|
||||
static let dataRange: ClosedRange<UInt16> = 0...1024
|
||||
let data: [UInt16]
|
||||
}
|
||||
@@ -38,7 +38,7 @@ extension EstimatedWaveform {
|
||||
}
|
||||
}
|
||||
|
||||
extension EstimatedWaveform {
|
||||
nonisolated extension EstimatedWaveform {
|
||||
static let mockWaveform = EstimatedWaveform(data: [0, 0, 0, 3, 3, 127, 400, 266, 126, 122, 373, 251, 45, 112,
|
||||
334, 205, 99, 138, 397, 354, 125, 361, 199, 51,
|
||||
294, 131, 19, 2, 3, 3, 1, 2, 0, 0,
|
||||
|
||||
Reference in New Issue
Block a user