Skip to content

Commit

Permalink
Fix retain cycle in UserSuggestionViewModel
Browse files Browse the repository at this point in the history
Steps to reproduce:

- Launch app
- Enter and leave a bunch of rooms
- Fire up the memory graph debugger
- Filter for `UserSuggestionViewModel`

Relates to: #5058
Signed-off-by: Johannes Marbach <[email protected]>
  • Loading branch information
Johennes authored and stefanceriu committed Mar 21, 2022
1 parent 6bd2462 commit c734d7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class UserSuggestionViewModel: UserSuggestionViewModelType, UserSuggestionViewMo

super.init(initialViewState: UserSuggestionViewState(items: items))

userSuggestionService.items.sink { items in
self.state.items = items.map({ item in
userSuggestionService.items.sink { [weak self] items in
self?.state.items = items.map({ item in
UserSuggestionViewStateItem(id: item.userId, avatar: item, displayName: item.displayName)
})
}.store(in: &cancellables)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5058.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UserSuggestionViewModel: Fix retain cycle

0 comments on commit c734d7c

Please sign in to comment.