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