From 99f5601330eea8473c1c25529b36b9628ee18e15 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:13:59 +0000 Subject: [PATCH] Fix a crash when blocking/unblocking a user (#2143) The view state doesn't like mutating an optional when built in release mode. --- .../RoomDetailsScreen/RoomDetailsScreenViewModel.swift | 10 ++++++++-- changelog.d/2140.bugfix | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelog.d/2140.bugfix diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift index fe8d27be4..242a9c63b 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift @@ -254,7 +254,10 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr state.isProcessingIgnoreRequest = false switch result { case .success: - state.dmRecipient?.isIgnored = true + // Mutating the optional in place when built for Release crashes 🤷‍♂️ + var dmRecipient = state.dmRecipient + dmRecipient?.isIgnored = true + state.dmRecipient = dmRecipient case .failure, .none: state.bindings.alertInfo = .init(id: .unknown) } @@ -266,7 +269,10 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr state.isProcessingIgnoreRequest = false switch result { case .success: - state.dmRecipient?.isIgnored = false + // Mutating the optional in place when built for Release crashes 🤷‍♂️ + var dmRecipient = state.dmRecipient + dmRecipient?.isIgnored = false + state.dmRecipient = dmRecipient case .failure, .none: state.bindings.alertInfo = .init(id: .unknown) } diff --git a/changelog.d/2140.bugfix b/changelog.d/2140.bugfix new file mode 100644 index 000000000..77749291f --- /dev/null +++ b/changelog.d/2140.bugfix @@ -0,0 +1 @@ +Fix a crash when blocking/unblocking a user from the DM details screen. \ No newline at end of file