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: element-hq#5058
Signed-off-by: Johannes Marbach <[email protected]>
  • Loading branch information
Johennes committed Mar 18, 2022
1 parent c3b231b commit 40650cb
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 40650cb

Please sign in to comment.