Skip to content

Commit

Permalink
Fix crashes when blocking/unblocking users
Browse files Browse the repository at this point in the history
- SwiftUI crashes when mutating optional state properties in place
- workaround it buy mutating a local reference first
  • Loading branch information
stefanceriu committed Mar 11, 2024
1 parent b0f109a commit 9ce12e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
state.isProcessingIgnoreRequest = false
switch result {
case .success:
state.memberDetails?.isIgnored = true
var details = state.memberDetails
details?.isIgnored = true
state.memberDetails = details

updateMembers()
case .failure:
state.bindings.alertInfo = .init(id: .unknown)
Expand All @@ -126,7 +129,10 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
state.isProcessingIgnoreRequest = false
switch result {
case .success:
state.memberDetails?.isIgnored = false
var details = state.memberDetails
details?.isIgnored = false
state.memberDetails = details

updateMembers()
case .failure:
state.bindings.alertInfo = .init(id: .unknown)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-2553.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crashes when blocking/unblocking users

0 comments on commit 9ce12e6

Please sign in to comment.