Re-enabled converation list observation while a conversation is open.

It honestly doesn't feel great to not have this, because when you back
out to the conversation list you have to wait for it to update.

Right now this seems like the lesser of two evils.
This commit is contained in:
Greyson Parrelli
2021-08-30 12:50:20 -04:00
committed by Cody Henthorne
parent eba3c55ec8
commit 32888fa00b
2 changed files with 2 additions and 18 deletions

View File

@@ -320,7 +320,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
super.onStart();
ConversationFragment.prepare(requireContext());
ApplicationDependencies.getAppForegroundObserver().addListener(appForegroundObserver);
viewModel.onStart();
}
@Override
@@ -336,7 +335,6 @@ public class ConversationListFragment extends MainFragment implements ActionMode
public void onStop() {
super.onStop();
ApplicationDependencies.getAppForegroundObserver().removeListener(appForegroundObserver);
viewModel.onStop();
}
@Override

View File

@@ -60,7 +60,6 @@ class ConversationListViewModel extends ViewModel {
private String activeQuery;
private SearchResult activeSearchResult;
private int pinnedCount;
private boolean isNewlyCreated;
private ConversationListViewModel(@NonNull Application application, @NonNull SearchRepository searchRepository, boolean isArchived) {
this.megaphone = new MutableLiveData<>();
@@ -87,7 +86,6 @@ class ConversationListViewModel extends ViewModel {
pagedData.getController().onDataInvalidated();
});
};
this.isNewlyCreated = true;
this.hasNoConversations = LiveDataUtil.mapAsync(pagedData.getData(), conversations -> {
pinnedCount = DatabaseFactory.getThreadDatabase(application).getPinnedConversationListCount();
@@ -98,6 +96,8 @@ class ConversationListViewModel extends ViewModel {
return DatabaseFactory.getThreadDatabase(application).getArchivedConversationListCount() == 0;
}
});
ApplicationDependencies.getDatabaseObserver().registerConversationListObserver(observer);
}
public LiveData<Boolean> hasNoConversations() {
@@ -142,20 +142,6 @@ class ConversationListViewModel extends ViewModel {
coldStart = false;
}
void onStart() {
if (!isNewlyCreated) {
pagedData.getController().onDataInvalidated();
}
isNewlyCreated = false;
ApplicationDependencies.getDatabaseObserver().registerConversationListObserver(observer);
}
void onStop() {
ApplicationDependencies.getDatabaseObserver().unregisterObserver(observer);
}
void onMegaphoneCompleted(@NonNull Megaphones.Event event) {
megaphone.postValue(null);
megaphoneRepository.markFinished(event);