Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

[INVESTIGATE] lastMessage incorrectly set as 'unread' when fetching room list #2569

Closed
luismachado opened this issue Mar 7, 2019 · 7 comments

Comments

@luismachado
Copy link
Contributor

Hello,

So I'm trying to implement read marks on the subscription list (to extend the already existing functionally inside the rooms) but I'm facing some weird behaviour from the API (so this might not be an issue with the app but with the server so I'm sorry if that's the case).

What happens is that when calling https://localhost:3000/api/v1/rooms.get?updatedSince=...] all the lastMessages for each subscription comes with the unread parameter set to false (even thou the message was already read, which I can confirm if I fetch the message list for the subscription).

Now, this also only happens because the updatedSince is set to a -100000 seconds timeframe from the server data (here). Why the 100000 seconds window?

Now I know reducing the time isn't a solution but I was curious on what might happen if I change the value.

@rafaelks
Copy link
Contributor

@luismachado Good question! I think we added this additional interval just to make sure to have the latest data, but removing it should not affect the results on unread parameter, because it will always return the latest data. Have you tried removing it?

@luismachado
Copy link
Contributor Author

From what i've been able to see (still have to investigate this further), when this aforementioned endpoint returns the lastmessages, it will overwrite the data for each of those messages (if they were already downloaded previously). Has they come with the incorrect unread value the last message for each channel is going to be affected (if I open each channel I'm able to see the last message marked as unread for a slight moment and then is updated to read, because the read endpoint is called when the channel is opened).

Now, if I set the updatedSince to 0 I think that what will happen is that the no messages will be returned (because nothing changed since a 0 ago..) so it won't overwrite anything. However, that way I won't ever fetch anything from the server (unless I then opened the channel).

@rafaelks rafaelks changed the title lastMessage incorrectly set as 'unread' when fetching room list [INVESTIGATE] lastMessage incorrectly set as 'unread' when fetching room list Mar 20, 2019
@luismachado
Copy link
Contributor Author

@rafaelks just to update this thread:
I have a parallel issue opened on the server git page here.

I've since found out that the updatedSince=... isn't necessary (I since pulled all the commits into my repo, which was a bit outdated, and the behaviour changed somehow). I'm seeing this behaviour now every time I log into the app (so, when the updatedSince=... isn't sent).

What's happening is that the data returned by the server says that the lastMessages are unread:true (when I know for a fact that they are read). Even weirder is that the response only includes the unread field on recent messages (it's weird because I'm not sending any time of filter. I'm guessing the backend does some sort of filter by itself here).

So, for older messages they stand marked as read but newer ones, initially, always are returned as unread.

@rafaelks
Copy link
Contributor

@luismachado The updatedSince is actually used so we don't need to return the whole list of rooms, and it should work properly. The unread property on the message being returned as false is kinda weird, but we don't use this property anyway... we use the property from the room object, you know?

@luismachado
Copy link
Contributor Author

@rafaelks hey. I explained myself incorrectly (again -.-'): I was trying to say that the updatedSince param wasn't needed to replicate/cause the issue :)

Regarding the unread property, I'm not modifying the code (only testing as it is) so if this property isn't being used than the other one, most likely, is also being returned as false (since the lastmessages on each channel appear as unread). However what I tried was to directly modify the server response (and change the unread field to true) and with that the messages appeared as read!

When you mention the room object is this also returned by the same endpoint or is it a separate call?

Finally, as I mentioned I have a parallel issue opened on the server git and I provide more context (and a reply sample) here.

@rafaelks
Copy link
Contributor

@luismachado You're right, I just realized that we actually use the unread property for showing read receipts when enabled. So, there's nothing to be fixed in the app at this point, right? 🤔

@luismachado
Copy link
Contributor Author

@rafaelks in the app itself it look like no! There is already a open PR to fix the issue, on the server :)

So I guess this one can be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants