mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-25 11:14:01 +00:00
Adopt latest SwiftFormat rules
Introduced in 0.64.0: repeatedGuard, nestedIf and extensionAttributes
This commit is contained in:
@@ -127,8 +127,8 @@ private enum FilterType {
|
|||||||
case auditType(XCUIAccessibilityAuditType)
|
case auditType(XCUIAccessibilityAuditType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
private extension Array where Element == FilterType {
|
private extension Array where Element == FilterType {
|
||||||
@MainActor
|
|
||||||
func isAccessibilityIssueFiltered(_ issue: XCUIAccessibilityAuditIssue) -> Bool {
|
func isAccessibilityIssueFiltered(_ issue: XCUIAccessibilityAuditIssue) -> Bool {
|
||||||
for filter in self {
|
for filter in self {
|
||||||
switch filter {
|
switch filter {
|
||||||
|
|||||||
@@ -191,9 +191,8 @@ private struct AccountProvisioningURLParser: URLParser {
|
|||||||
let domain: String
|
let domain: String
|
||||||
|
|
||||||
func route(from url: URL) -> AppRoute? {
|
func route(from url: URL) -> AppRoute? {
|
||||||
guard url.host() == domain else { return nil }
|
guard url.host() == domain,
|
||||||
|
let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
|
||||||
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
|
|
||||||
let serverName = components.queryItems?.first(where: { $0.name == AccountProvisioningParameters.CodingKeys.accountProvider.rawValue })?.value else {
|
let serverName = components.queryItems?.first(where: { $0.name == AccountProvisioningParameters.CodingKeys.accountProvider.rawValue })?.value else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -309,10 +309,9 @@ import SwiftUI
|
|||||||
/// Manually process changes to the compact layout navigation stack and update embedded components
|
/// Manually process changes to the compact layout navigation stack and update embedded components
|
||||||
/// We need to either: pop from the detail, nil the detail or pop from the sidebar
|
/// We need to either: pop from the detail, nil the detail or pop from the sidebar
|
||||||
private func processCompactLayoutStackModuleRemoval(_ module: NavigationModule) {
|
private func processCompactLayoutStackModuleRemoval(_ module: NavigationModule) {
|
||||||
if let sidebarNavigationStackCoordinator = sidebarModule?.coordinator as? NavigationStackCoordinator {
|
if let sidebarNavigationStackCoordinator = sidebarModule?.coordinator as? NavigationStackCoordinator,
|
||||||
if sidebarNavigationStackCoordinator.stackModules.contains(module) {
|
sidebarNavigationStackCoordinator.stackModules.contains(module) {
|
||||||
sidebarNavigationStackCoordinator.stackModules.removeAll { $0 == module }
|
sidebarNavigationStackCoordinator.stackModules.removeAll { $0 == module }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if module == detailModule {
|
if module == detailModule {
|
||||||
|
|||||||
@@ -207,15 +207,9 @@ private class PassthroughWindow: UIWindow {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
guard let hitView = super.hitTest(point, with: event) else {
|
guard let hitView = super.hitTest(point, with: event),
|
||||||
return nil
|
let rootViewController,
|
||||||
}
|
hitView != self else {
|
||||||
|
|
||||||
guard let rootViewController else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
guard hitView != self else {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,17 +63,13 @@ class MediaEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
presentation: .mediaFilesScreen,
|
presentation: .mediaFilesScreen,
|
||||||
roomProxy: roomProxy,
|
roomProxy: roomProxy,
|
||||||
timelineItemFactory: timelineItemFactory,
|
timelineItemFactory: timelineItemFactory,
|
||||||
mediaProvider: userSession.mediaProvider) else {
|
mediaProvider: userSession.mediaProvider),
|
||||||
MXLog.error("Failed presenting media timeline")
|
case let .success(filesTimelineController) = await flowParameters.timelineControllerFactory.buildMessageFilteredTimelineController(focus: .live,
|
||||||
return
|
allowedMessageTypes: [.file, .audio, .gallery],
|
||||||
}
|
presentation: .mediaFilesScreen,
|
||||||
|
roomProxy: roomProxy,
|
||||||
guard case let .success(filesTimelineController) = await flowParameters.timelineControllerFactory.buildMessageFilteredTimelineController(focus: .live,
|
timelineItemFactory: timelineItemFactory,
|
||||||
allowedMessageTypes: [.file, .audio, .gallery],
|
mediaProvider: userSession.mediaProvider) else {
|
||||||
presentation: .mediaFilesScreen,
|
|
||||||
roomProxy: roomProxy,
|
|
||||||
timelineItemFactory: timelineItemFactory,
|
|
||||||
mediaProvider: userSession.mediaProvider) else {
|
|
||||||
MXLog.error("Failed presenting media timeline")
|
MXLog.error("Failed presenting media timeline")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ struct BannedRoomProxyMockConfiguration {
|
|||||||
var members: [RoomMemberProxyMock] = .allMembers
|
var members: [RoomMemberProxyMock] = .allMembers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension BannedRoomProxyMock {
|
extension BannedRoomProxyMock {
|
||||||
@MainActor
|
|
||||||
convenience init(_ configuration: BannedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: BannedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
@@ -27,8 +27,9 @@ extension BannedRoomProxyMock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension RoomInfoProxyMock {
|
extension RoomInfoProxyMock {
|
||||||
@MainActor convenience init(_ configuration: BannedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: BannedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ struct InvitedRoomProxyMockConfiguration {
|
|||||||
var inviter: RoomMemberProxyMock = .mockAlice
|
var inviter: RoomMemberProxyMock = .mockAlice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension InvitedRoomProxyMock {
|
extension InvitedRoomProxyMock {
|
||||||
@MainActor
|
|
||||||
convenience init(_ configuration: InvitedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: InvitedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
@@ -32,8 +32,9 @@ extension InvitedRoomProxyMock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension RoomInfoProxyMock {
|
extension RoomInfoProxyMock {
|
||||||
@MainActor convenience init(_ configuration: InvitedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: InvitedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ struct JoinedRoomProxyMockConfiguration {
|
|||||||
var powerLevelsConfiguration = RoomPowerLevelsProxyMock.Configuration()
|
var powerLevelsConfiguration = RoomPowerLevelsProxyMock.Configuration()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension JoinedRoomProxyMock {
|
extension JoinedRoomProxyMock {
|
||||||
@MainActor
|
|
||||||
convenience init(_ configuration: JoinedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: JoinedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
@@ -143,8 +143,9 @@ extension JoinedRoomProxyMock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension RoomInfoProxyMock {
|
extension RoomInfoProxyMock {
|
||||||
@MainActor convenience init(_ configuration: JoinedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: JoinedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ struct KnockedRoomProxyMockConfiguration {
|
|||||||
var members: [RoomMemberProxyMock] = .allMembers
|
var members: [RoomMemberProxyMock] = .allMembers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension KnockedRoomProxyMock {
|
extension KnockedRoomProxyMock {
|
||||||
@MainActor
|
|
||||||
convenience init(_ configuration: KnockedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: KnockedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
@@ -27,8 +27,9 @@ extension KnockedRoomProxyMock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension RoomInfoProxyMock {
|
extension RoomInfoProxyMock {
|
||||||
@MainActor convenience init(_ configuration: KnockedRoomProxyMockConfiguration) {
|
convenience init(_ configuration: KnockedRoomProxyMockConfiguration) {
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
id = configuration.id
|
id = configuration.id
|
||||||
|
|||||||
@@ -35,11 +35,10 @@ extension MediaProviderMock {
|
|||||||
let data = try? Data(contentsOf: url) {
|
let data = try? Data(contentsOf: url) {
|
||||||
return UIImage(data: data)
|
return UIImage(data: data)
|
||||||
}
|
}
|
||||||
} else if mediaSource?.url == .mockMXCUserAvatar {
|
} else if mediaSource?.url == .mockMXCUserAvatar,
|
||||||
if let url = Bundle.main.url(forResource: "preview_avatar_user", withExtension: "jpg"),
|
let url = Bundle.main.url(forResource: "preview_avatar_user", withExtension: "jpg"),
|
||||||
let data = try? Data(contentsOf: url) {
|
let data = try? Data(contentsOf: url) {
|
||||||
return UIImage(data: data)
|
return UIImage(data: data)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return UIImage(systemName: "photo")
|
return UIImage(systemName: "photo")
|
||||||
|
|||||||
@@ -82,9 +82,11 @@ public extension UIImage {
|
|||||||
|
|
||||||
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)
|
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)
|
||||||
|
|
||||||
guard let provider = CGDataProvider(data: data) else { return nil }
|
guard let provider = CGDataProvider(data: data),
|
||||||
guard let cgImage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 24, bytesPerRow: bytesPerRow,
|
let cgImage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 24, bytesPerRow: bytesPerRow,
|
||||||
space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: bitmapInfo, provider: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent) else { return nil }
|
space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: bitmapInfo, provider: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
self.init(cgImage: cgImage)
|
self.init(cgImage: cgImage)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ nonisolated enum AVMetadataBinaryValueError: Error {
|
|||||||
nonisolated extension AVMetadataMachineReadableCodeObject {
|
nonisolated extension AVMetadataMachineReadableCodeObject {
|
||||||
var qrBinaryValue: Data? {
|
var qrBinaryValue: Data? {
|
||||||
get throws(AVMetadataBinaryValueError) {
|
get throws(AVMetadataBinaryValueError) {
|
||||||
guard type == .qr else { return nil }
|
guard type == .qr, let qrCodeDescriptor = descriptor as? CIQRCodeDescriptor else { return nil }
|
||||||
|
|
||||||
guard let qrCodeDescriptor = descriptor as? CIQRCodeDescriptor else { return nil }
|
|
||||||
return try Self.removeQRProtocolData(qrCodeDescriptor.errorCorrectedPayload, symbolVersion: qrCodeDescriptor.symbolVersion)
|
return try Self.removeQRProtocolData(qrCodeDescriptor.errorCorrectedPayload, symbolVersion: qrCodeDescriptor.symbolVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ import Foundation
|
|||||||
import Observation
|
import Observation
|
||||||
import Synchronization
|
import Synchronization
|
||||||
|
|
||||||
|
@MainActor
|
||||||
extension Observable {
|
extension Observable {
|
||||||
/// A convenience wrapper around the `Observations` sequence (SE-0475).
|
/// A convenience wrapper around the `Observations` sequence (SE-0475).
|
||||||
///
|
///
|
||||||
/// - Parameter property: The key path to the property you would like to observe.
|
/// - Parameter property: The key path to the property you would like to observe.
|
||||||
@available(iOS 26.0, *)
|
@available(iOS 26.0, *)
|
||||||
@MainActor func observe<Value: Sendable>(_ property: KeyPath<Self, Value>) -> Observations<Value, Never> {
|
func observe<Value: Sendable>(_ property: KeyPath<Self, Value>) -> Observations<Value, Never> {
|
||||||
Observations { self[keyPath: property] }
|
Observations { self[keyPath: property] }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ extension Observable {
|
|||||||
/// - Parameter property: The key path to the property you would like to observe.
|
/// - Parameter property: The key path to the property you would like to observe.
|
||||||
@available(iOS, deprecated: 26.0, message: "Use observe(_:) which is backed by the Observations sequence.")
|
@available(iOS, deprecated: 26.0, message: "Use observe(_:) which is backed by the Observations sequence.")
|
||||||
@_disfavoredOverload
|
@_disfavoredOverload
|
||||||
@MainActor func observe<Value: Sendable>(_ property: KeyPath<Self, Value>) -> AsyncStream<Value> {
|
func observe<Value: Sendable>(_ property: KeyPath<Self, Value>) -> AsyncStream<Value> {
|
||||||
let (stream, continuation) = AsyncStream<Value>.makeStream()
|
let (stream, continuation) = AsyncStream<Value>.makeStream()
|
||||||
let (changeSignals, changeSignaller) = AsyncStream<Void>.makeStream()
|
let (changeSignals, changeSignaller) = AsyncStream<Void>.makeStream()
|
||||||
|
|
||||||
|
|||||||
@@ -429,21 +429,20 @@ nonisolated struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
|||||||
|
|
||||||
func addMatrixEntityPermalinkAttributesTo(_ attributedString: NSMutableAttributedString) {
|
func addMatrixEntityPermalinkAttributesTo(_ attributedString: NSMutableAttributedString) {
|
||||||
attributedString.enumerateAttribute(.link, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
|
attributedString.enumerateAttribute(.link, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
|
||||||
if value != nil {
|
if value != nil,
|
||||||
if let url = value as? URL,
|
let url = value as? URL,
|
||||||
let matrixEntity = parseMatrixEntityFrom(uri: url.absoluteString) {
|
let matrixEntity = parseMatrixEntityFrom(uri: url.absoluteString) {
|
||||||
switch matrixEntity.id {
|
switch matrixEntity.id {
|
||||||
case .user(let userID):
|
case .user(let userID):
|
||||||
mentionBuilder.handleUserMention(for: attributedString, in: range, url: url, userID: userID, userDisplayName: nil)
|
mentionBuilder.handleUserMention(for: attributedString, in: range, url: url, userID: userID, userDisplayName: nil)
|
||||||
case .room(let roomID):
|
case .room(let roomID):
|
||||||
mentionBuilder.handleRoomIDMention(for: attributedString, in: range, url: url, roomID: roomID)
|
mentionBuilder.handleRoomIDMention(for: attributedString, in: range, url: url, roomID: roomID)
|
||||||
case .roomAlias(let alias):
|
case .roomAlias(let alias):
|
||||||
mentionBuilder.handleRoomAliasMention(for: attributedString, in: range, url: url, roomAlias: alias, roomDisplayName: nil)
|
mentionBuilder.handleRoomAliasMention(for: attributedString, in: range, url: url, roomAlias: alias, roomDisplayName: nil)
|
||||||
case .eventOnRoomId(let roomID, let eventID):
|
case .eventOnRoomId(let roomID, let eventID):
|
||||||
mentionBuilder.handleEventOnRoomIDMention(for: attributedString, in: range, url: url, eventID: eventID, roomID: roomID)
|
mentionBuilder.handleEventOnRoomIDMention(for: attributedString, in: range, url: url, eventID: eventID, roomID: roomID)
|
||||||
case .eventOnRoomAlias(let alias, let eventID):
|
case .eventOnRoomAlias(let alias, let eventID):
|
||||||
mentionBuilder.handleEventOnRoomAliasMention(for: attributedString, in: range, url: url, eventID: eventID, roomAlias: alias)
|
mentionBuilder.handleEventOnRoomAliasMention(for: attributedString, in: range, url: url, eventID: eventID, roomAlias: alias)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
@available(iOS 26, *)
|
||||||
extension View {
|
extension View {
|
||||||
/// Similar to the `.glassProminent` button style, `.glassEffect` breaks our preview tests so this modifier provides a fallback.
|
/// Similar to the `.glassProminent` button style, `.glassEffect` breaks our preview tests so this modifier provides a fallback.
|
||||||
/// https://github.com/pointfreeco/swift-snapshot-testing/issues/1029#issuecomment-3366942138
|
/// https://github.com/pointfreeco/swift-snapshot-testing/issues/1029#issuecomment-3366942138
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@available(iOS 26, *)
|
|
||||||
func snapshotableGlassEffect(_ glass: Glass, snapshotBackground: Color, in shape: some Shape) -> some View {
|
func snapshotableGlassEffect(_ glass: Glass, snapshotBackground: Color, in shape: some Shape) -> some View {
|
||||||
if !ProcessInfo.isRunningUnitTests {
|
if !ProcessInfo.isRunningUnitTests {
|
||||||
glassEffect(glass, in: shape)
|
glassEffect(glass, in: shape)
|
||||||
|
|||||||
@@ -157,11 +157,10 @@ class EditRoomAddressScreenViewModel: EditRoomAddressScreenViewModelType, EditRo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then try remove the old alias from the room directory on our current HS
|
// Then try remove the old alias from the room directory on our current HS
|
||||||
if let savedAliasFromHomeserver {
|
if let savedAliasFromHomeserver,
|
||||||
if case .failure = await roomProxy.removeRoomAliasFromRoomDirectory(savedAliasFromHomeserver) {
|
case .failure = await roomProxy.removeRoomAliasFromRoomDirectory(savedAliasFromHomeserver) {
|
||||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||||
return
|
return
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally update the canonical alias state..
|
// Finally update the canonical alias state..
|
||||||
|
|||||||
@@ -148,9 +148,11 @@ class TimelineMediaPreviewViewModel: TimelineMediaPreviewViewModelType {
|
|||||||
setCurrentItem(previewItem)
|
setCurrentItem(previewItem)
|
||||||
|
|
||||||
if case let .media(mediaItem) = previewItem {
|
if case let .media(mediaItem) = previewItem {
|
||||||
guard mediaItem.fileHandle == nil, let source = mediaItem.mediaSource else { return }
|
guard mediaItem.fileHandle == nil,
|
||||||
|
let source = mediaItem.mediaSource,
|
||||||
guard await checkSourceIsSafeIfNeeded(for: mediaItem, source: source) else { return }
|
await checkSourceIsSafeIfNeeded(for: mediaItem, source: source) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch await mediaProvider.loadFileFromSource(source, filename: mediaItem.filename) {
|
switch await mediaProvider.loadFileFromSource(source, filename: mediaItem.filename) {
|
||||||
case .success(let handle):
|
case .success(let handle):
|
||||||
|
|||||||
+1
-2
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Compound
|
import Compound
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
struct TimelineMediaPreviewDetailsView: View {
|
struct TimelineMediaPreviewDetailsView: View {
|
||||||
let item: TimelineMediaPreviewItem.Media
|
let item: TimelineMediaPreviewItem.Media
|
||||||
@@ -167,8 +168,6 @@ struct TimelineMediaPreviewDetailsView: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import UniformTypeIdentifiers
|
|
||||||
|
|
||||||
@available(iOS 26.0, *)
|
@available(iOS 26.0, *)
|
||||||
struct TimelineMediaPreviewDetailsView_Previews: PreviewProvider, TestablePreview {
|
struct TimelineMediaPreviewDetailsView_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = makeViewModel(contentType: .jpeg, isOutgoing: true)
|
static let viewModel = makeViewModel(contentType: .jpeg, isOutgoing: true)
|
||||||
|
|||||||
+1
-2
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Compound
|
import Compound
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import UniformTypeIdentifiers
|
||||||
|
|
||||||
struct TimelineMediaPreviewRedactConfirmationView: View {
|
struct TimelineMediaPreviewRedactConfirmationView: View {
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@@ -122,8 +123,6 @@ struct TimelineMediaPreviewRedactConfirmationView: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import UniformTypeIdentifiers
|
|
||||||
|
|
||||||
struct TimelineMediaPreviewRedactConfirmationView_Previews: PreviewProvider, TestablePreview {
|
struct TimelineMediaPreviewRedactConfirmationView_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = makeViewModel(contentType: .jpeg)
|
static let viewModel = makeViewModel(contentType: .jpeg)
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
import Compound
|
import Compound
|
||||||
|
import MatrixRustSDKMocks
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct HomeScreenInviteCell: View {
|
struct HomeScreenInviteCell: View {
|
||||||
@@ -154,8 +155,6 @@ struct HomeScreenInviteCell: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import MatrixRustSDKMocks
|
|
||||||
|
|
||||||
struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
|
struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
import Compound
|
import Compound
|
||||||
|
import MatrixRustSDKMocks
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct HomeScreenKnockedCell: View {
|
struct HomeScreenKnockedCell: View {
|
||||||
@@ -97,8 +98,6 @@ struct HomeScreenKnockedCell: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import MatrixRustSDKMocks
|
|
||||||
|
|
||||||
struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
|
struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
import Compound
|
import Compound
|
||||||
|
import MatrixRustSDKMocks
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct HomeScreenRoomCell: View {
|
struct HomeScreenRoomCell: View {
|
||||||
@@ -195,8 +196,6 @@ private extension View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import MatrixRustSDKMocks
|
|
||||||
|
|
||||||
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||||
static let summaryProviderGeneric = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
static let summaryProviderGeneric = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
||||||
static let genericRooms = summaryProviderGeneric.roomListPublisher.value.compactMap { mockRoom(summary: $0) }
|
static let genericRooms = summaryProviderGeneric.roomListPublisher.value.compactMap { mockRoom(summary: $0) }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Compound
|
import Compound
|
||||||
|
import MatrixRustSDKMocks
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct QRCodeLoginScreen: View {
|
struct QRCodeLoginScreen: View {
|
||||||
@@ -323,8 +324,6 @@ private struct QRScannerViewOverlay: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import MatrixRustSDKMocks
|
|
||||||
|
|
||||||
struct QRCodeLoginScreen_Previews: PreviewProvider, TestablePreview {
|
struct QRCodeLoginScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
// Instructions
|
// Instructions
|
||||||
static let loginInstructionsStateViewModel = QRCodeLoginScreenViewModel.mock(state: .loginInstructions)
|
static let loginInstructionsStateViewModel = QRCodeLoginScreenViewModel.mock(state: .loginInstructions)
|
||||||
|
|||||||
@@ -332,19 +332,17 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if roomProxy.infoPublisher.value.isDM {
|
if roomProxy.infoPublisher.value.isDM {
|
||||||
if var dmRecipientInfo = state.dmRecipientInfo {
|
if var dmRecipientInfo = state.dmRecipientInfo,
|
||||||
if case let .success(userIdentity) = await userSession.clientProxy.userIdentity(for: dmRecipientInfo.member.id, fallBackToServer: true) {
|
case let .success(userIdentity) = await userSession.clientProxy.userIdentity(for: dmRecipientInfo.member.id, fallBackToServer: true) {
|
||||||
dmRecipientInfo.verificationState = userIdentity?.verificationState
|
dmRecipientInfo.verificationState = userIdentity?.verificationState
|
||||||
state.dmRecipientInfo = dmRecipientInfo
|
state.dmRecipientInfo = dmRecipientInfo
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for member in roomProxy.membersPublisher.value {
|
for member in roomProxy.membersPublisher.value {
|
||||||
if case let .success(userIdentity) = await userSession.clientProxy.userIdentity(for: member.userID, fallBackToServer: false) {
|
if case let .success(userIdentity) = await userSession.clientProxy.userIdentity(for: member.userID, fallBackToServer: false),
|
||||||
if userIdentity?.verificationState == .verificationViolation {
|
userIdentity?.verificationState == .verificationViolation {
|
||||||
state.hasMemberIdentityVerificationStateViolations = true
|
state.hasMemberIdentityVerificationStateViolations = true
|
||||||
return
|
return
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Compound
|
import Compound
|
||||||
|
import MatrixRustSDK
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct RoomDetailsScreen: View {
|
struct RoomDetailsScreen: View {
|
||||||
@@ -357,8 +358,6 @@ struct RoomDetailsScreen: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import MatrixRustSDK
|
|
||||||
|
|
||||||
@available(iOS 26.0, *)
|
@available(iOS 26.0, *)
|
||||||
struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static let genericWorldReadableRoomViewModel = makeGenericRoomViewModel(historyVisibility: .worldReadable)
|
static let genericWorldReadableRoomViewModel = makeGenericRoomViewModel(historyVisibility: .worldReadable)
|
||||||
|
|||||||
+8
-6
@@ -96,8 +96,10 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func toogleCustomSetting() {
|
private func toogleCustomSetting() {
|
||||||
guard case .loaded(let settings) = state.notificationSettingsState else { return }
|
guard case .loaded(let settings) = state.notificationSettingsState,
|
||||||
guard state.bindings.allowCustomSetting == settings.isDefault else { return }
|
state.bindings.allowCustomSetting == settings.isDefault else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if state.bindings.allowCustomSetting {
|
if state.bindings.allowCustomSetting {
|
||||||
setCustomMode(settings.mode)
|
setCustomMode(settings.mode)
|
||||||
@@ -122,10 +124,10 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
|
|||||||
|
|
||||||
private func setCustomMode(_ mode: RoomNotificationModeProxy) {
|
private func setCustomMode(_ mode: RoomNotificationModeProxy) {
|
||||||
// Check if the new mode is already the current one
|
// Check if the new mode is already the current one
|
||||||
if case .loaded(let currentSettings) = state.notificationSettingsState {
|
if case .loaded(let currentSettings) = state.notificationSettingsState,
|
||||||
if !currentSettings.isDefault, currentSettings.mode == mode {
|
!currentSettings.isDefault,
|
||||||
return
|
currentSettings.mode == mode {
|
||||||
}
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state.pendingCustomMode = mode
|
state.pendingCustomMode = mode
|
||||||
|
|||||||
+1
-1
@@ -112,7 +112,7 @@ struct SecurityAndPrivacyScreenViewState: BindableState {
|
|||||||
var shouldShowAccessSectionFooter: Bool {
|
var shouldShowAccessSectionFooter: Bool {
|
||||||
if (bindings.desiredSettings.accessType.isSpaceMembers && isSpaceMembersOptionSelectable) ||
|
if (bindings.desiredSettings.accessType.isSpaceMembers && isSpaceMembersOptionSelectable) ||
|
||||||
(bindings.desiredSettings.accessType.isAskToJoinWithSpaceMembers && isAskToJoinWithSpaceMembersOptionSelectable),
|
(bindings.desiredSettings.accessType.isAskToJoinWithSpaceMembers && isAskToJoinWithSpaceMembersOptionSelectable),
|
||||||
case .multiple = spaceSelection {
|
case .multiple = spaceSelection {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Compound
|
import Compound
|
||||||
|
import MatrixRustSDK
|
||||||
|
import MatrixRustSDKMocks
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LeaveSpaceView: View {
|
struct LeaveSpaceView: View {
|
||||||
@@ -126,9 +128,6 @@ struct LeaveSpaceView: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
import MatrixRustSDK
|
|
||||||
import MatrixRustSDKMocks
|
|
||||||
|
|
||||||
struct LeaveSpaceView_Previews: PreviewProvider, TestablePreview {
|
struct LeaveSpaceView_Previews: PreviewProvider, TestablePreview {
|
||||||
static let manyViewModel = makeViewModel(mode: .manyRooms)
|
static let manyViewModel = makeViewModel(mode: .manyRooms)
|
||||||
static let onlyAdminViewModel = makeViewModel(mode: .roomsNeedNewOwner)
|
static let onlyAdminViewModel = makeViewModel(mode: .roomsNeedNewOwner)
|
||||||
|
|||||||
@@ -280,8 +280,11 @@ class LiveLocationManager: NSObject, LiveLocationManagerProtocol, CLLocationMana
|
|||||||
/// This ensures at least 3 seconds or the send duration itself between consecutive sends,
|
/// This ensures at least 3 seconds or the send duration itself between consecutive sends,
|
||||||
/// discarding any intermediate updates while always keeping the last one.
|
/// discarding any intermediate updates while always keeping the last one.
|
||||||
private func processLocationUpdateIfNeeded() {
|
private func processLocationUpdateIfNeeded() {
|
||||||
guard !isProcessingLocationUpdate, let location = latestPendingLocation else { return }
|
guard !isProcessingLocationUpdate,
|
||||||
guard !userSettings.app.liveLocationSharingSessionsByRoomID.isEmpty else { return }
|
let location = latestPendingLocation,
|
||||||
|
!userSettings.app.liveLocationSharingSessionsByRoomID.isEmpty else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
latestPendingLocation = nil
|
latestPendingLocation = nil
|
||||||
isProcessingLocationUpdate = true
|
isProcessingLocationUpdate = true
|
||||||
|
|||||||
@@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
|
||||||
|
|
||||||
@preconcurrency import MatrixRustSDK
|
@preconcurrency import MatrixRustSDK
|
||||||
|
import UIKit
|
||||||
|
|
||||||
actor MediaLoader: MediaLoaderProtocol {
|
actor MediaLoader: MediaLoaderProtocol {
|
||||||
// We noticed that the keyboard appears to hold onto a reference to the `Context` of the last
|
// We noticed that the keyboard appears to hold onto a reference to the `Context` of the last
|
||||||
|
|||||||
@@ -83,11 +83,8 @@ final class PresenceService {
|
|||||||
|
|
||||||
private func reportCurrentState() {
|
private func reportCurrentState() {
|
||||||
let presence = desiredPresence
|
let presence = desiredPresence
|
||||||
guard sendTask != nil || presence != lastSentPresence else {
|
guard sendTask != nil || presence != lastSentPresence,
|
||||||
return
|
pendingPresence != presence else {
|
||||||
}
|
|
||||||
|
|
||||||
guard pendingPresence != presence else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,11 +88,8 @@ final class RoomDirectorySearchProxy: RoomDirectorySearchProxyProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private nonisolated static func processDiff(_ diff: RoomDirectorySearchEntryUpdate, on currentItems: [RoomDirectorySearchResult]) -> [RoomDirectorySearchResult] {
|
private nonisolated static func processDiff(_ diff: RoomDirectorySearchEntryUpdate, on currentItems: [RoomDirectorySearchResult]) -> [RoomDirectorySearchResult] {
|
||||||
guard let collectionDiff = buildDiff(from: diff, on: currentItems) else {
|
guard let collectionDiff = buildDiff(from: diff, on: currentItems),
|
||||||
return currentItems
|
let updatedItems = currentItems.applying(collectionDiff) else {
|
||||||
}
|
|
||||||
|
|
||||||
guard let updatedItems = currentItems.applying(collectionDiff) else {
|
|
||||||
return currentItems
|
return currentItems
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,11 +88,9 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
|||||||
// MARK: - Preview
|
// MARK: - Preview
|
||||||
|
|
||||||
func startPlayback() async -> Result<Void, VoiceMessageRecorderError> {
|
func startPlayback() async -> Result<Void, VoiceMessageRecorderError> {
|
||||||
guard let previewAudioPlayerState, let url = audioRecorder.audioFileURL else {
|
guard let previewAudioPlayerState,
|
||||||
return .failure(.previewNotAvailable)
|
let url = audioRecorder.audioFileURL,
|
||||||
}
|
let audioPlayer = previewAudioPlayer else {
|
||||||
|
|
||||||
guard let audioPlayer = previewAudioPlayer else {
|
|
||||||
return .failure(.previewNotAvailable)
|
return .failure(.previewNotAvailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,14 +211,13 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
|
|||||||
MXLog.info("audio recorder did stop recording")
|
MXLog.info("audio recorder did stop recording")
|
||||||
if !recordingCancelled {
|
if !recordingCancelled {
|
||||||
Task {
|
Task {
|
||||||
guard case .success = await finalizeRecording() else {
|
guard case .success = await finalizeRecording(),
|
||||||
actionsSubject.send(.didFailWithError(error: VoiceMessageRecorderError.previewNotAvailable))
|
let recordingURL = audioRecorder.audioFileURL,
|
||||||
return
|
let previewAudioPlayerState else {
|
||||||
}
|
|
||||||
guard let recordingURL = audioRecorder.audioFileURL, let previewAudioPlayerState else {
|
|
||||||
actionsSubject.send(.didFailWithError(error: VoiceMessageRecorderError.previewNotAvailable))
|
actionsSubject.send(.didFailWithError(error: VoiceMessageRecorderError.previewNotAvailable))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaPlayerProvider.register(audioPlayerState: previewAudioPlayerState)
|
mediaPlayerProvider.register(audioPlayerState: previewAudioPlayerState)
|
||||||
actionsSubject.send(.didStopRecording(previewState: previewAudioPlayerState, url: recordingURL))
|
actionsSubject.send(.didStopRecording(previewState: previewAudioPlayerState, url: recordingURL))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,8 +170,8 @@ private extension PreviewDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
private extension Snapshotting where Value: SwiftUI.View, Format == UIImage {
|
private extension Snapshotting where Value: SwiftUI.View, Format == UIImage {
|
||||||
@MainActor
|
|
||||||
static func prefireImage(drawHierarchyInKeyWindow: Bool = false,
|
static func prefireImage(drawHierarchyInKeyWindow: Bool = false,
|
||||||
preferences: SnapshotPreferences,
|
preferences: SnapshotPreferences,
|
||||||
layout: SwiftUISnapshotLayout = .sizeThatFits,
|
layout: SwiftUISnapshotLayout = .sizeThatFits,
|
||||||
|
|||||||
Reference in New Issue
Block a user