HabitRPG / habitica-android

Native Android app for Habitica
GNU General Public License v3.0
1.41k stars 508 forks source link

Liking messages in party chat doesn't always update like count as expected #2051

Closed jsoberg closed 4 months ago

jsoberg commented 8 months ago

Describe the bug I was fixing the issue in #1861 and noticed that while the click callback was being called and we were contacting server to update the message likes, the like count does not always react to these changes in the list. I'm separating this out into its own bug report since it doesn't involve the touch target issue from #1861.

To Reproduce Steps to reproduce the behavior:

  1. Open a party chat.
  2. Like or unlike someone else's message.
  3. Repeat until like count does not update as expected.

Expected behavior The like count should update each time that you like and unlike the message.

Screenshots (clicking on an emulator often through this recording, some updates show and some don't). studio64_6nvwlvRCZf

Smartphone (please complete the following information):

Additional context

There appear to be a few issues here that I can see at an initial glance:

  1. SocialRepositoryImpl.likeMessage always returns null, and therefore we never submit an update for that message in GroupViewModel.likeMessage.
  2. RealmSocialLocalRepository.likeMessage doesn't update when the message is already liked, so when we go from liked to unliked we don't make any local changes.

After addressing these issues locally and doing a little debugging, it seems like the message returned from apiClient.likeMessage still ends up not being changed on some calls, so I'm wondering if this could also potentially be an issue on the server and/or an issue with submitting the change within a certain time interval and being ignored.