-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
fix: #1352 - robotoff insight card shows permanently #1574
Conversation
@teolemon, could you please check why the workflow "Add bugs to the Release Smoothie GitHub Project" failed? thanks |
on it @cli1005 |
fixed @cli1005 |
There was a problem hiding this 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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, | ||
queryType: OpenFoodAPIConfiguration.globalQueryType); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
return ListTile( | ||
leading: const CircularProgressIndicator(), | ||
title: Text(title), | ||
); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
return ListTile( | ||
leading: const CircularProgressIndicator(), | ||
title: Text(title), | ||
); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@cli1005 Is that open or closed? |
closed for fixing pre-submit test issues, now it's ok |
There was a problem hiding this 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( |
There was a problem hiding this comment.
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.
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'; |
There was a problem hiding this comment.
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.
static const String _hiveBoxName = 'robotoffMap'; | ||
static const String _key = 'votedHistory'; |
There was a problem hiding this comment.
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.
RobotoffQuestionsQuery(this._barcode); | ||
final String _barcode; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
…com/cli1005/smooth-app into bug/1352-robotoff-insight-card-loop
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 :
Screenshot
simulator-screen-recording-iphone-13-2022-04-13-at-163702_08ZSUGyO.mp4
Fixes bug(s)