Only force a conversation list re-query for non-cold-starts.

This commit is contained in:
Greyson Parrelli 2020-12-20 09:22:10 -05:00 committed by Alan Evans
parent fcbd594def
commit 1ced115b54

View file

@ -33,6 +33,8 @@ class ConversationListViewModel extends ViewModel {
private static final String TAG = Log.tag(ConversationListViewModel.class); private static final String TAG = Log.tag(ConversationListViewModel.class);
private static boolean coldStart = true;
private final MutableLiveData<Megaphone> megaphone; private final MutableLiveData<Megaphone> megaphone;
private final MutableLiveData<SearchResult> searchResult; private final MutableLiveData<SearchResult> searchResult;
private final PagedData<Conversation> pagedData; private final PagedData<Conversation> pagedData;
@ -104,9 +106,14 @@ class ConversationListViewModel extends ViewModel {
void onVisible() { void onVisible() {
megaphoneRepository.getNextMegaphone(megaphone::postValue); megaphoneRepository.getNextMegaphone(megaphone::postValue);
if (!coldStart) {
ApplicationDependencies.getDatabaseObserver().notifyConversationListListeners(); ApplicationDependencies.getDatabaseObserver().notifyConversationListListeners();
} }
coldStart = false;
}
void onMegaphoneCompleted(@NonNull Megaphones.Event event) { void onMegaphoneCompleted(@NonNull Megaphones.Event event) {
megaphone.postValue(null); megaphone.postValue(null);
megaphoneRepository.markFinished(event); megaphoneRepository.markFinished(event);