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

fix: #1352 - robotoff insight card shows permanently #1574

Merged

Conversation

cli1005
Copy link
Contributor

@cli1005 cli1005 commented Apr 14, 2022

What

The Robotoff insight card ("🥇 card") persists on the product page which is supposed to be hided after having answering all the questions.

Root cause : Comment issues

Solutions :

  • Turn LoadingDialog to future builder
  • Create new hive box to cache vote history
  • More details : Comment soultions

Screenshot

simulator-screen-recording-iphone-13-2022-04-13-at-163702_08ZSUGyO.mp4

Fixes bug(s)

@cli1005 cli1005 requested a review from a team as a code owner April 14, 2022 09:05
@cli1005
Copy link
Contributor Author

cli1005 commented Apr 14, 2022

@teolemon, could you please check why the workflow "Add bugs to the Release Smoothie GitHub Project" failed? thanks

@teolemon
Copy link
Member

on it @cli1005

@teolemon teolemon linked an issue Apr 14, 2022 that may be closed by this pull request
@teolemon teolemon added this to the V1 milestone Apr 14, 2022
@teolemon
Copy link
Member

fixed @cli1005

@teolemon teolemon requested a review from monsieurtanuki April 17, 2022 17:52
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cli1005!
Good things and bad things in your PR: please have a look at my comments and ask me if needed.

@@ -160,4 +162,51 @@ class ProductQueryModel with ChangeNotifier {
.toList();
}
}

static Future<void> cacheInsightAnnotationVoted(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something doesn't feel right here: the rest of the file is about a class that gets instantiated.
Here everything you add are static methods that don't seem to have any connection with this specific class.
I suggest that you create another class in another file. Possibly a class with a LocalDatabase parameter in the constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Future<bool> existsInsight(final String insightId) async {
final Map<String, List<String>> value = await getAll();
bool esixts = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Future<bool> existsInsight(final String insightId) async {
final Map<String, List<String>> value = await getAll();
bool esixts = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false;
}

Future<bool> removeInsight(final String insightId) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeStringValue would be more meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false;
}

Future<bool> removeInsight(final String insightId) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removeStringValue would be more meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 67 to 69
final ProductResult result = await OpenFoodAPIClient.getProduct(
configuration,
queryType: OpenFoodAPIConfiguration.globalQueryType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep it the way it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -68,7 +68,7 @@ class LoadingDialog<T> {
(final T value) => _popDialog(context, value),
);
// TODO(monsieurtanuki): is that safe? If the future finishes before the "return" call?
return _getDialog(context, title);
return _getDialog(context, title, future);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you don't have to call the future just before, do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -68,7 +68,7 @@ class LoadingDialog<T> {
(final T value) => _popDialog(context, value),
);
// TODO(monsieurtanuki): is that safe? If the future finishes before the "return" call?
return _getDialog(context, title);
return _getDialog(context, title, future);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you don't have to call the future just before, do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 98 to 101
return ListTile(
leading: const CircularProgressIndicator(),
title: Text(title),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we're not here anymore. If you really need to return something, a Container will do. Not something that looks interesting but will only add confusion to the code reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 98 to 101
return ListTile(
leading: const CircularProgressIndicator(),
title: Text(title),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we're not here anymore. If you really need to return something, a Container will do. Not something that looks interesting but will only add confusion to the code reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cli1005 cli1005 closed this Apr 21, 2022
@cli1005 cli1005 reopened this Apr 21, 2022
@M123-dev M123-dev requested a review from monsieurtanuki April 21, 2022 08:04
@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2022

Codecov Report

Merging #1574 (9faf821) into develop (2ea0da3) will decrease coverage by 0.11%.
The diff coverage is 1.60%.

@@            Coverage Diff             @@
##           develop   #1574      +/-   ##
==========================================
- Coverage     8.86%   8.74%   -0.12%     
==========================================
  Files          161     164       +3     
  Lines         6623    6771     +148     
==========================================
+ Hits           587     592       +5     
- Misses        6036    6179     +143     
Impacted Files Coverage Δ
...rds/knowledge_panels/knowledge_panels_builder.dart 2.17% <0.00%> (ø)
...s/product_cards/smooth_product_card_not_found.dart 0.00% <0.00%> (ø)
...mooth_app/lib/data_models/product_query_model.dart 1.38% <ø> (ø)
...s/smooth_app/lib/data_models/user_preferences.dart 34.42% <ø> (+2.11%) ⬆️
...s/smooth_app/lib/database/dao_string_list_map.dart 0.00% <0.00%> (ø)
...ckages/smooth_app/lib/database/local_database.dart 0.00% <0.00%> (ø)
...s/smooth_app/lib/database/paged_product_query.dart 0.00% <0.00%> (ø)
...oth_app/lib/database/robotoff_questions_query.dart 0.00% <0.00%> (ø)
...ric_lib/buttons/smooth_large_button_with_icon.dart 0.00% <0.00%> (ø)
...ges/smooth_app/lib/generic_lib/loading_dialog.dart 0.00% <0.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75b677c...9faf821. Read the comment docs.

@cli1005 cli1005 closed this Apr 21, 2022
@cli1005 cli1005 reopened this Apr 21, 2022
@monsieurtanuki
Copy link
Contributor

@cli1005 Is that open or closed?

@cli1005
Copy link
Contributor Author

cli1005 commented Apr 21, 2022

@cli1005 Is that open or closed?

closed for fixing pre-submit test issues, now it's ok

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @cli1005 for your quick fixes!
Please have a look at my comments: among them you'll see that you missed an await.
Fix that and push, and then we're done :)

@@ -160,4 +162,51 @@ class ProductQueryModel with ChangeNotifier {
.toList();
}
}

static Future<void> cacheInsightAnnotationVoted(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something doesn't feel right here: the rest of the file is about a class that gets instantiated.
Here everything you add are static methods that don't seem to have any connection with this specific class.
I suggest that you create another class in another file. Possibly a class with a LocalDatabase parameter in the constructor.

Comment on lines 4 to 7
import 'package:smooth_app/database/dao_string_list_map.dart';
import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/database/product_query.dart';
import 'package:smooth_app/database/robotoff_questions_query.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove those additional imports: we don't need them anymore.

Comment on lines +8 to +9
static const String _hiveBoxName = 'robotoffMap';
static const String _key = 'votedHistory';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course that will have to be changed when we have another use for DaoStringListMap, but for the moment that's OK.

Comment on lines +6 to +7
RobotoffQuestionsQuery(this._barcode);
final String _barcode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't do that again: for me it's an additional file to check, with no added value as your only change is making the barcode private.

@@ -294,6 +295,9 @@ class _ProductListPageState extends State<ProductListPage> {
}
await DaoProduct(localDatabase).putAll(freshProducts);
freshProducts.forEach(productList.refresh);
final RobotoffInsightHelper robotoffInsightHelper =
RobotoffInsightHelper(localDatabase);
robotoffInsightHelper.clearInsightAnnotationsSaved();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final ProductResult result =
await OpenFoodAPIClient.getProduct(configuration);
final ProductResult result = await OpenFoodAPIClient.getProduct(
configuration,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, that's the only contribution on this file: I have to review this file for one comma that nobody complained about!
If you had to do something more relevant in this file and in the meanwhile correct here and there the presentation, why not, but without that please don't include that in a PR.

@cli1005 cli1005 merged commit f671807 into openfoodfacts:develop Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Robotoff refresh bug brings me into a loop
4 participants