-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore existing Robotoff questions (#6130)
- Loading branch information
Showing
3 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/smooth_app/lib/helpers/robotoff_question_helper.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
|
||
extension RobotoffQuestionHelper on List<RobotoffQuestion> { | ||
bool areSameAs(List<RobotoffQuestion> questions) { | ||
return equals(questions, RobotoffQuestionsEquality()); | ||
} | ||
} | ||
|
||
class RobotoffQuestionsEquality implements Equality<RobotoffQuestion> { | ||
@override | ||
bool equals(RobotoffQuestion e1, RobotoffQuestion e2) => | ||
e1.insightId == e2.insightId; | ||
|
||
@override | ||
int hash(RobotoffQuestion e) => e.insightId.hashCode; | ||
|
||
@override | ||
bool isValidKey(Object? o) { | ||
if (o is RobotoffQuestion) { | ||
return true; | ||
} | ||
throw UnimplementedError(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters