fix message comparator

This commit is contained in:
Daniel Gultsch 2023-03-27 11:18:29 +02:00
parent cc07f86bf4
commit d52cbb8e8c
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
4 changed files with 5 additions and 9 deletions

View file

@ -13,7 +13,6 @@ public class ChatOverviewComparator extends DiffUtil.ItemCallback<ChatOverviewIt
@Override @Override
public boolean areItemsTheSame( public boolean areItemsTheSame(
@NonNull ChatOverviewItem oldItem, @NonNull ChatOverviewItem newItem) { @NonNull ChatOverviewItem oldItem, @NonNull ChatOverviewItem newItem) {
// LOGGER.info("areItemsTheSame({},{})", oldItem.id, newItem.id);
return oldItem.id == newItem.id; return oldItem.id == newItem.id;
} }

View file

@ -21,10 +21,10 @@ public class MessageComparator extends DiffUtil.ItemCallback<MessageWithContentR
public boolean areContentsTheSame( public boolean areContentsTheSame(
@NonNull MessageWithContentReactions oldItem, @NonNull MessageWithContentReactions oldItem,
@NonNull MessageWithContentReactions newItem) { @NonNull MessageWithContentReactions newItem) {
final var equals = oldItem.equals(newItem); final var areContentsTheSame = oldItem.equals(newItem);
if (!equals) { if (!areContentsTheSame) {
LOGGER.info("Message {} got modified", oldItem.id); LOGGER.info("Message {} got modified", oldItem.id);
} }
return false; return areContentsTheSame;
} }
} }

View file

@ -53,10 +53,7 @@ public class ChatFragment extends Fragment {
.getMessages() .getMessages()
.observe( .observe(
getViewLifecycleOwner(), getViewLifecycleOwner(),
pagingData -> { pagingData -> messageAdapter.submitData(getLifecycle(), pagingData));
LOGGER.info("submitData()");
messageAdapter.submitData(getLifecycle(), pagingData);
});
this.binding.materialToolbar.setNavigationOnClickListener( this.binding.materialToolbar.setNavigationOnClickListener(
view -> { view -> {
NavControllers.findNavController(requireActivity(), R.id.nav_host_fragment) NavControllers.findNavController(requireActivity(), R.id.nav_host_fragment)

View file

@ -39,7 +39,7 @@ public class ChatViewModel extends AndroidViewModel {
chatId -> { chatId -> {
final Pager<Integer, MessageWithContentReactions> pager = final Pager<Integer, MessageWithContentReactions> pager =
new Pager<>( new Pager<>(
new PagingConfig(30), new PagingConfig(50),
() -> chatRepository.getMessages(chatId)); () -> chatRepository.getMessages(chatId));
return PagingLiveData.getLiveData(pager); return PagingLiveData.getLiveData(pager);
}); });