Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resynchronize rooms upon reconnection to catch missing content #253

Closed
quinthar opened this issue Aug 19, 2020 · 4 comments · Fixed by #275
Closed

Resynchronize rooms upon reconnection to catch missing content #253

quinthar opened this issue Aug 19, 2020 · 4 comments · Fixed by #275
Assignees

Comments

@quinthar
Copy link
Contributor

Right now when you come back into a room, there's a good chance that messages were sent to you while offline that you missed. Depending on how long you've been offline, it might reconnect from scratch and redownload everything, or just continue the room without noticing the missed messages. I think we need to solve for super-reliable synching, which might change how we store data, request from the API, etc.

@tgolen
Copy link
Contributor

tgolen commented Aug 20, 2020

@marcaaron and I had an idea for this, which does change a little bit about how Ion gets data from the network, but it should be a pretty neat solution.

Ideally

  1. Have a way to configure Ion so that it knows "for key X, it loads data from the network by calling method Y" (let's call this a loader method).
  2. Each loader will have a cache strategy of onReconnect, onFirstAccess (we could later add things like never, always, expires, etc.)
  3. For loaders with onFirstAccess, the first time that any key is accessed in Ion, it will return any data that is already in persistent data then call the loader method, which will fetch any new data and put it straight into Ion (triggering changes in the UI automatically)
  4. For loaders with onReconnect, they will be called when the app comes back from being offline.

Quick-n-dirty

  1. For every action that loads data into Ion (fetching reports, fetching report history, fetching personal details), have them hard-coded to be called once the app comes back from being offline.

So I think we can implement the quick-n-dirty one right away while we continue to explore a more optimal and scalable solution down the road.

@tgolen tgolen self-assigned this Aug 20, 2020
@cead22
Copy link
Contributor

cead22 commented Aug 20, 2020

I like the quick and dirty, the "ideal" solution sounds overly complicated. I'd even take the quick and dirty a step further, and just have the report (chat) page poll while it's open to make sure its data is up to date

@marcaaron
Copy link
Contributor

marcaaron commented Aug 20, 2020

@cead22 I would favor a solution that doesn't include anymore timers. We should really focus on figuring out how to reliably detect connection and disconnect... this PR of mine addresses this concern via using the NetInfo package and we should give that a chance.

I don't mind abstract loader idea for when a component mounts @tgolen, but less sure that we need each individual loader to have fine grained settings or logic about exactly what to do on reconnect. And I don't think we even need to abstract the loaders - but I agree we should consider it (step 1 of your ideal proposal)

Ion already has awareness of what keys are "connected" to it right? (via callbackToStateMapping maybe?)

So we can create a method like Ion.reloadConnectedKeys() that reduces all the state keys it needs to update, makes them unique, and then calls each loader method that corresponds with that state key.

When connectivity resumes we can just do Ion.reloadConnectedKeys()

@cead22
Copy link
Contributor

cead22 commented Aug 20, 2020

We should really focus on figuring out how to reliably detect connection and disconnect...

I agree with that 100%, but that doesn't cover all cases

  • You post a comment
  • You go offline
  • I post a comment
  • You come online
  • The app won't load my comment, we'll need to make a new api call to get the latest comments on a report

So we can create a method like Ion.reloadConnectedKeys() that reduces all the state keys it needs to update, makes them unique, and then calls each loader method that corresponds with that state key.

Mostly I'm trying to avoid a solution that solves this in a generic way for use cases we don't know we have, vs solving the problem we know we have.

We can add fancy loaders, or we can make explicit api calls when on the report page.

That said, we don't have to do this via polling, we could just make the api calls when we disconnect and then re-connect, but that means connection detection has to be 100% reliable, or the app will suck when this fails, as it won't display all the comments on the report

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

Successfully merging a pull request may close this issue.

4 participants