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

Link the on-page add category button now that the dedicated section is working #2244

Closed
1 task
teolemon opened this issue Jun 10, 2022 · 7 comments · Fixed by #2276
Closed
1 task

Link the on-page add category button now that the dedicated section is working #2244

teolemon opened this issue Jun 10, 2022 · 7 comments · Fixed by #2276
Assignees
Milestone

Comments

@teolemon
Copy link
Member

What

  • Link the on-page add category button now that the dedicated section is working
@teolemon teolemon added this to the V1 milestone Jun 10, 2022
@monsieurtanuki monsieurtanuki self-assigned this Jun 10, 2022
@monsieurtanuki
Copy link
Contributor

@teolemon Actually I'm a bit stuck here, as I'm a bit in conflict with @cli1005's #2201, the current SummaryPage and #1593. There are contradictory demands about behavior offline or with slow connectivity. And there seems to be a special case with picture upload.

Main question: should it be possible to edit data when offline?
My guess is that the answer is "no". When we edit a product, we save the modifications to the server and get the full refreshed product from the server. If the answer were "yes", it would cause confusion between a local version of the product and the server version, not only for the modified fields but for all the computed fields.

Related question: should we have a different behavior for image uploads?
My guess is that the answer is "yes". There are performances and therefore UX issues with large data like picture upload. And there are already related issues, like #2192 #1724 #1623 #1593 #1398 #917 #863 #513.

@teolemon
Copy link
Member Author

@AshAman999 for the Offline Smoothie reflexion

@AshAman999
Copy link
Member

Main question: should it be possible to edit data when offline? My guess is that the answer is "no". When we edit a product, we save the modifications to the server and get the full refreshed product from the server. If the answer were "yes", it would cause confusion between a local version of the product and the server version, not only for the modified fields but for all the computed fields.

For the GSoC 22, https://docs.google.com/document/d/1qRkbZwtkASM3_BNhZSkFEekkhrllddR4Tv69bCdquPs/edit?usp=sharing
It was proposed to enable the offline edit as well,
Somehow, we need to send the changes to the server later on if in case the edits were done in no network zone,

A possible solution that I am thinking of is to keep a queue of the edited tasks
Like keeping in a record probably a SQL-based DB the 1 barcode, the 2 type of edit made (Nutrition table, Nutrients,..etc and, the 3 edited values and sending the changes one at a time when the network connects and deleting from the front

For the case of refreshing the product, we can either update the local cache when we actually send the edits to the server and get the response or maybe precisely when the edit is done(assuming the server returns a successful status ).

That being said, here now comes again the question of the selection #1840 (comment) for no SQL or SQL based DB for offline dump, since a large volume of data is to be dumped, considering that hive might not be a good choice,
thus reducing the possible candidates to Sqflite or moor ( now known as drift)

@monsieurtanuki, @teolemon @g123k , @M123-dev
Should we now switch back to the good old SQL?

@monsieurtanuki
Copy link
Contributor

@AshAman999 Thank you for your message.

What you unfortunately don't deal with are

  1. server-computed fields like scores - could be a frustrating experience to change an ingredient in order to make it vegetarian, and not seeing the vegetarian flag set to green
  2. the added complexity on the app in read mode - a product is not only the product already stored on the database, but with all the pending changes on top

Regarding the product refresh, we already send the changes and get the fresh product back.

I don't think we're talking about a large volume of data: we're only talking about atomic changes on products. So far I don't see a good reason in disqualifying hive, especially with its "lazy" mode (that we already use successfully for product data) - we could create a new lazy table with the barcode as primary key and the list of each change as field.

Besides, the pictures are dealt with in another issue - there we're talking about

  • much bigger volumes (pics)
  • much probable use case (pictures in a shop is more probable than changing a single data) (just my experience)

@AshAman999
Copy link
Member

@monsieurtanuki Thanks for your reply

I don't think we're talking about a large volume of data: we're only talking about atomic changes on products. So far I don't see a good reason in disqualifying hive, especially with its "lazy" mode (that we already use successfully for product data) - we could create a new lazy table with the barcode as primary key and the list of each change as field.

Apart from not just storing the atomic changes on products, there has been proposed to keep a local DB for the top most used products in a country, that value I am guessing would be a bit large in number is to be done within this 3 months,

Analyzing and looking at your earlier comments left along many PRs I got the conclusion that hive will perform well till the DB is small, but since the local DB dump might be large here the startup time for the app can be big, so to reduce that SQFLite should be bought back.
It's not just for storing the atomic changes but to also make the work smooth even if the offline data dump DB contains more than 3k products for one country(maybe user can want to keep data for another country as well)

server-computed fields like scores - could be a frustrating experience to change an ingredient in order to make it vegetarian, and not seeing the vegetarian flag set to green

I believe we can just a snack bar that the data will be refreshed as soon as they connect to the network, and since we get a full product when we send the changes to the server that means we can then just update the local DB with the same updated details for that barcode/product

Besides, the pictures are dealt with in another issue - there we're talking about
much bigger volumes (pics)
much probable use case (pictures in a shop is more probable than changing a single data) (just my experience)

Had a look at the comments related to work manager there, I think we can upload the full resolution picture to the server till we need it and then have a miniature picture for the local cache or maybe discard the idea for the miniature images in local cache if the sizes become too large and yeah that's another issue for now

@monsieurtanuki
Copy link
Contributor

Apart from not just storing the atomic changes on products, there has been proposed to keep a local DB for the top most used products in a country, that value I am guessing would be a bit large in number is to be done within this 3 months,

Then it's another topic, much more ambitious, that would deserve its own github issue, wouldn't it?

Analyzing and looking at your earlier comments left along many PRs I got the conclusion that hive will perform well till the DB is small, but since the local DB dump might be large here the startup time for the app can be big, so to reduce that SQFLite should be bought back.

That could be tested again regarding hive and the expected size of the database, but indeed with sqflite the startup is immediate, regardless of the size of the database.

It's not just for storing the atomic changes but to also make the work smooth even if the offline data dump DB contains more than 3k products for one country(maybe user can want to keep data for another country as well)

Therefore if it's just about storing atomic changes we can keep hive, if we consider only the size of the changed data.

I believe we can just a snack bar that the data will be refreshed as soon as they connect to the network, and since we get a full product when we send the changes to the server that means we can then just update the local DB with the same updated details for that barcode/product

OK for the warning snackbar.
You still don't address the computed fields like nutriscore until the network is available; you'd better display a very relevant message in your snackbar.

Regardless, my initial questions were just about an "add categories" button, and I don't think we should wait until all your 3K products / sqflite / offline code is merged.
If I sum up there are ambitious expected offline features, possibly merged in the next 3 months, and in the meanwhile we may assume that the network is always available.

@monsieurtanuki
Copy link
Contributor

For the record I'm currently working on a more flutter-ish method, based on providers, in the spirit of https://docs.flutter.dev/development/data-and-backend/state-mgmt/simple

monsieurtanuki added a commit to monsieurtanuki/smooth-app that referenced this issue Jun 14, 2022
…t provider refactoring

New file:
* `up_to_date_product_provider.dart`: Provider that reflects all the user changes on [Product]s.

Impacted files:
* `add_basic_details_page.dart`: refactoring
* `category_picker_page.dart`: refactoring
* `edit_ingredients_page.dart`: refactoring around `UpToDateProductProvider`
* `edit_product_page.dart`: refactoring around `UpToDateProductProvider`
* `knowledge_panel_page_template.dart`: refactored for code clarity
* `knowledge_panels_builder.dart`: refactored for code clarity
* `main.dart`: added `UpToDateProductProvider` in the provider list
* `new_product_page.dart`: refactoring around `UpToDateProductProvider`; removed deprecated code on "additional button"
* `Podfile.lock`: wtf
* `product_list_page.dart`: refactored around `UpToDateProductProvider`
* `product_refresher.dart`: refactored around `UpToDateProductProvider`
* `simple_input_page.dart`: refactored
* `summary_card.dart`: implemented "add categories" button; refactored around `UpToDateProductProvider`
@teolemon teolemon modified the milestones: V1, V1.1 Jun 18, 2022
monsieurtanuki added a commit that referenced this issue Jun 19, 2022
…factoring (#2276)

New file:
* `up_to_date_product_provider.dart`: Provider that reflects all the user changes on [Product]s.

Impacted files:
* `add_basic_details_page.dart`: refactoring
* `category_picker_page.dart`: refactoring
* `edit_ingredients_page.dart`: refactoring around `UpToDateProductProvider`
* `edit_product_page.dart`: refactoring around `UpToDateProductProvider`
* `knowledge_panel_page_template.dart`: refactored for code clarity
* `knowledge_panels_builder.dart`: refactored for code clarity
* `main.dart`: added `UpToDateProductProvider` in the provider list
* `new_product_page.dart`: refactoring around `UpToDateProductProvider`; removed deprecated code on "additional button"
* `Podfile.lock`: wtf
* `product_list_page.dart`: refactored around `UpToDateProductProvider`
* `product_refresher.dart`: refactored around `UpToDateProductProvider`
* `simple_input_page.dart`: refactored
* `summary_card.dart`: implemented "add categories" button; refactored around `UpToDateProductProvider`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment