Skip to content

Commit

Permalink
fix: no longer using deprecated API method getKnowledgePanels (#1066)
Browse files Browse the repository at this point in the history
Impacted files:
* `knwoledge_panels_query.dart`: no longer using deprecated API method getKnowledgePanels
* `pubspec.lock`: impacted by `pubpsec.yaml`
* `pubspec.yaml`: upgraded `openfoodfacts`
  • Loading branch information
monsieurtanuki authored Feb 3, 2022
1 parent 7d8e9c2 commit 4dd0ab1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/smooth_app/lib/database/knowledge_panels_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';

import 'package:openfoodfacts/model/KnowledgePanels.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:openfoodfacts/utils/OpenFoodAPIConfiguration.dart';
import 'package:smooth_app/database/product_query.dart';

class KnowledgePanelsQuery {
Expand All @@ -17,10 +16,18 @@ class KnowledgePanelsQuery {
barcode,
language: ProductQuery.getLanguage(),
country: ProductQuery.getCountry(),
fields: <ProductField>[ProductField.KNOWLEDGE_PANELS],
version: ProductQueryVersion.v2,
);
return OpenFoodAPIClient.getKnowledgePanels(
configuration,
OpenFoodAPIConfiguration.globalQueryType,
);

try {
final ProductResult productResult = await OpenFoodAPIClient.getProduct(
configuration,
);
return productResult.product!.knowledgePanels!;
} catch (exception) {
// TODO(jasmeetsingh): Capture the exception in Sentry and don't log it here.
return KnowledgePanels.empty();
}
}
}

0 comments on commit 4dd0ab1

Please sign in to comment.