Fix rendering issue when deleting the last message in a conversation.

This commit is contained in:
Greyson Parrelli 2020-12-09 14:39:22 -05:00
parent ffc0a230be
commit ec8793c6fe
2 changed files with 11 additions and 2 deletions

View file

@ -250,8 +250,11 @@ public class ConversationFragment extends LoggingFragment {
this.messageCountsViewModel = ViewModelProviders.of(requireActivity()).get(MessageCountsViewModel.class);
this.conversationViewModel = ViewModelProviders.of(requireActivity(), new ConversationViewModel.Factory()).get(ConversationViewModel.class);
conversationViewModel.getMessages().observe(this, list -> {
getListAdapter().submitList(list);
conversationViewModel.getMessages().observe(this, messages -> {
ConversationAdapter adapter = getListAdapter();
if (adapter != null) {
getListAdapter().submitList(messages);
}
});
conversationViewModel.getConversationMetadata().observe(this, this::presentConversationMetadata);

View file

@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
@ -57,6 +58,11 @@ class FixedSizePagingController<E> implements PagingController {
return;
}
if (loadState.size() == 0) {
liveData.postValue(Collections.emptyList());
return;
}
int leftPageBoundary = (aroundIndex / config.pageSize()) * config.pageSize();
int rightPageBoundary = leftPageBoundary + config.pageSize();
int buffer = config.bufferPages() * config.pageSize();