Skip to content

Commit

Permalink
Ensure old typing observers are unsubscribed.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Mar 30, 2020
1 parent 728ec1c commit af2e17d
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -398,6 +398,8 @@ private static void presentMessageRequestProfileView(@NonNull Context context, @
}

private void initializeResources() {
long oldThreadId = threadId;

this.recipient = Recipient.live(getActivity().getIntent().getParcelableExtra(ConversationActivity.RECIPIENT_EXTRA));
this.threadId = this.getActivity().getIntent().getLongExtra(ConversationActivity.THREAD_ID_EXTRA, -1);
this.lastSeen = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
Expand All @@ -407,6 +409,10 @@ private void initializeResources() {

OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
list.addOnScrollListener(scrollListener);

if (oldThreadId != threadId) {
ApplicationContext.getInstance(requireContext()).getTypingStatusRepository().getTypists(oldThreadId).removeObservers(this);
}
}

private void initializeListAdapter() {
Expand Down Expand Up @@ -440,6 +446,7 @@ private void initializeTypingObserver() {
return;
}

ApplicationContext.getInstance(requireContext()).getTypingStatusRepository().getTypists(threadId).removeObservers(this);
ApplicationContext.getInstance(requireContext()).getTypingStatusRepository().getTypists(threadId).observe(this, typingState -> {
List<Recipient> recipients;
boolean replacedByIncomingMessage;
Expand Down

0 comments on commit af2e17d

Please sign in to comment.