-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Background + offline incoherences on multiple offline edits #3018
Comments
This sounds similar to performing commits on git. what if we handle this like priority queue? All local changes are prioritized over server retrieval. if server retrieval is in execution, local changes will be executed afterwards and server will be re-fetched? (not sure about this) |
Maybe, I don't understand that much about git - and I don't intend to.
Sounds correct, except that we need a decent UX for that - like the "cannot refresh product while there are local changes pending" message I was mentioning before.
How do you do that? For the moment, the background process execution is first the "upload changes" (
That's more or less my "solution 3". |
@monsieurtanuki There was something similar like sol 1 in my mind to do I believe that a mix of sol 1 and sol 3 would work the best,
|
upload changes => download product
upload changes => new_local_changes => download product if download is in progress, we can either stop it and perform upload of new_local_changes first or we can wait for download to complete then perform the flow of upload and download again? |
We need to update the local changes instantly. Then queue a background process that uploads, then downloads, then stores locally.
I don't think we can stop an Sharing views on that issue, I think we should just ignore whatever user data refresh (pull-to-refresh, search) from the server while there are pending tasks in general. |
I just want a solution that works - possibly bullet proof. Solution 1 so far looks like a "nice to have" and won't solve the main issue. Which means we can forget it. When all the major bugs are solved, then we can think about it again. We won't show an error snack bar from a background process. Or with difficulties. I don't think we need a provider, we just need a notifier. Like I don't know |
If somehow upload fails, then we'll need to revert back local changes?
yeah, this can be used CancelableOperation
Yeah, can add an indicator on top to let user know that they can't refresh due to background tasks |
That's a good point: I have no idea what we are supposed to do if upload fails.
Yes and no: the server will still process the data, it's just that the returned value on flutter will be irrelevant, right?
Not that easy, as the retry process of background tasks sometimes waits 3 hours before launching again. |
@teolemon @AshAman999 @anshpathania7 So if I had to sum up today's brainstorming, we are currently stuck with this question: << What are we supposed to do when a background "update product" process fails? >>
|
Yes, it will only cancel async tasks on flutter side, irrespective of Api. This might also be helpful in knowing which tasks were failed so we can revert local changes for it
if 5 retry methods fail, Or we can stack up all tasks to execute in slots, like having 4 slots of 6 hours interval, post execution queue is cleared, so it can be used in next time slot |
We cannot use slots: we want the data to be uploaded to the server as soon as internet is available. |
what if slots are only used for failed upload tasks? (which were failed even after 5 retries) |
In those cases I always ask myself: how do other apps do? It looks like Evernote does it that way:
Which inspires me several things:
|
Sounds good to me, so in queue of changed products, each product will have all changes to that specific product? (Like queue of Product Object, where Object holds all changes to that product) ?
Yes, adding this globally would be better, like showing it on top of every screen
Or we can explicitly mention to sync local changes first then refresh |
@anshpathania7 I'm not sure exactly if we can do that currently, so let's check first! @AshAman999 @g123k If I've understood well, for the moment there's a queue of background tasks, handled by the task manager. That sounds cool, we just add tasks and let the manager manage.
Is that doable with the current task manager? |
I think I've found a solution in order to merge all the tasks related to a product. Today, when we add a task we say something like "for barcode 0123, change category to XXX". What if instead of adding this task in the task manager, we created a dedicated sqflite table that would contain the same changes, and we just add to the task manager a simple task like |
Hello @monsieurtanuki, The solution you are suggesting does looks promising, We can request details about what was given to the Task object when we scheduled the task,
I am not sure about which way to go, perhaps I can work on the one I am suggesting, and see if works, |
@AshAman999 I guess your algorithm makes sense. That said, the added value of the task manager is to queue tasks and run them when the internet connection is OK. It's supposed to be a black box that does that very well. As we have functional needs that go beyond the standard use of the task manager, we should keep the functional features in smoothie (including the task merge) and the task queuing in task manager. Of course we could do everything with task manager if our needs were simpler, like "for a barcode, execute only the latest task". To be discussed. Anyway, it's not the priority now: I just mentioned our requirements to double-check that in the end, we'll have something that works in all cases. The priority now is to get rid of |
I have done none for now, first I guess if we could refresh views after the background task is done, would be a good start Then we could do about the consideration of merging changes into one. |
@AshAman999 OK, I go on with my changes then. I'll keep you posted. |
@monsieurtanuki How is this preventing notifying the app? Like what's the expected behaviour? |
New file: * `dao_transient_operation.dart`: Transient operation: a minimalist product with a key. Impacted files: * `barcode_product_query.dart`: minor refactoring * `local_database.dart`: added reference to new class `DaoTransientOperation` * `Podfile.lock`: wtf * `product_refresher.dart`: minor refactoring * `pubspec.lock`: wtf
Thank you @M123-dev! |
Yeah you are right, don't know why it closes, maybe because of your commit name |
What
Assuming that I use the app offline and that I change a product 5 times in a row (changes A, B, C, D and E), there are 5 background processes pending, all on the same product.
When I go online, I may have problems.
The more I think about it, the more I believe that solution 3 would solve everything (we wouldn't need solutions 1 and 2).
@AshAman999 Do you share my views?
The text was updated successfully, but these errors were encountered: