mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 04:06:14 +00:00
Stop listening to database changes in conversation list when not visible.
This commit is contained in:
@@ -320,6 +320,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
||||
super.onStart();
|
||||
ConversationFragment.prepare(requireContext());
|
||||
ApplicationDependencies.getAppForegroundObserver().addListener(appForegroundObserver);
|
||||
viewModel.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,6 +336,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
ApplicationDependencies.getAppForegroundObserver().removeListener(appForegroundObserver);
|
||||
viewModel.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,8 +96,6 @@ class ConversationListViewModel extends ViewModel {
|
||||
return DatabaseFactory.getThreadDatabase(application).getArchivedConversationListCount() == 0;
|
||||
}
|
||||
});
|
||||
|
||||
ApplicationDependencies.getDatabaseObserver().registerConversationListObserver(observer);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> hasNoConversations() {
|
||||
@@ -142,6 +140,14 @@ class ConversationListViewModel extends ViewModel {
|
||||
coldStart = false;
|
||||
}
|
||||
|
||||
void onStart() {
|
||||
ApplicationDependencies.getDatabaseObserver().registerConversationListObserver(observer);
|
||||
}
|
||||
|
||||
void onStop() {
|
||||
ApplicationDependencies.getDatabaseObserver().unregisterObserver(observer);
|
||||
}
|
||||
|
||||
void onMegaphoneCompleted(@NonNull Megaphones.Event event) {
|
||||
megaphone.postValue(null);
|
||||
megaphoneRepository.markFinished(event);
|
||||
|
||||
Reference in New Issue
Block a user