RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.64k stars 10.64k forks source link

[IMPROVEMENT] Merge Rooms + Subscriptions API & RealTime #11576

Open rafaelks opened 6 years ago

rafaelks commented 6 years ago

Description:

We want to merge Rooms and Subscriptions objects in one API to avoid having missing values at any time on the clients and also to avoid making two requests every time the apps needs to update the data and having two realtime (subscription) calls every time something changes.

The idea is to replace the API rooms.get and subscriptions.get returning everything in only one API. Also, create one subscription on the WebSocket connection that will let the clients know about the changes in both Rooms and Subscriptions.

Progress

rafaelks commented 6 years ago

Just making sure someone adjusts the milestone here from 0.69 to the correct one @rodrigok

geekgonecrazy commented 4 years ago

@diegolmello I think this was requested with mobile in mind. Is this still something needed or should we close this?

diegolmello commented 4 years ago

I didn't know about this opened issue, but it's still a thing. We still need to make 2 requests to get 1 info and listen/receive 2 socket updates for 1 object. I'm sure we can think on something. Keep it open 😊

geekgonecrazy commented 4 years ago

https://github.com/RocketChat/Rocket.Chat/pull/11808 Can’t figure out why this wasn’t released then 🙈

diegolmello commented 4 years ago

Damn! The socket part is still missing though, but ༼ つ ◕_◕ ༽つ

sampaiodiego commented 4 years ago

I don't think returning both results but in a single request helps that much.. there are many others requests being made during client startup that will not be combined and can have the same issues.

Having a real time stream is even worse as a room update may not trigger a subscription update so why the need to send both?

Maybe we need to define a new entity that represents the relation between rooms and users and have an API for that new entity.

diegolmello commented 4 years ago

I don't think returning both results but in a single request helps that much

It does. WatermelonDB is async. When those requests are made we need to fetch all subscriptions from db (asynchronously on JS, so there's a gap) and build all create/update/delete operations. And it's done on app startup, so there's a dispute for processing with the other requests (settings, rules, permissions, etc).

Same for socket. When both room and subscription are updated, we receive two records (one for each). We have a couple of window rules to try merging them into one DML operation instead of updating twice. For this reason, updates received via socket have a delay of 500ms (window time). If we receive them merged already, updates can be done instantly.