I am currently building an app that saves the user's blog post in Firestore
server. Everything is working fine, but I found out that the post was not uploaded under the unstable internet connection.
I tried to set a timeout to the Firestore
instance, but it seems like there's no timeout option for Firestore library. The problem is, because there's no timeout setting, the app doesn't know when to dismiss the uploading screen (Spinner dialog).
I was thinking about creating a Handler
or Observable
or Thread
and setting the timeout manually. After the specified timeout period, let the app dismiss the uploading screen. However, Firestore client will keep retrying the upload in the background even after the timeout. So this approach won't be suitable for this case...
Is there any solution for this? If I can set the timeout for the Firestore client itself, meaning letting the client to call onFailure()
after the given timeout period, I can just save the post as draft in the local storage and try it again when the device is back to stable connection.