From 4dd0ab1360557c611fa80901c9843e49791659a9 Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Thu, 3 Feb 2022 16:05:11 +0100 Subject: [PATCH] fix: no longer using deprecated API method getKnowledgePanels (#1066) Impacted files: * `knwoledge_panels_query.dart`: no longer using deprecated API method getKnowledgePanels * `pubspec.lock`: impacted by `pubpsec.yaml` * `pubspec.yaml`: upgraded `openfoodfacts` --- .../lib/database/knowledge_panels_query.dart | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/smooth_app/lib/database/knowledge_panels_query.dart b/packages/smooth_app/lib/database/knowledge_panels_query.dart index d3343f3f52b..a15438b7eb6 100644 --- a/packages/smooth_app/lib/database/knowledge_panels_query.dart +++ b/packages/smooth_app/lib/database/knowledge_panels_query.dart @@ -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 { @@ -17,10 +16,18 @@ class KnowledgePanelsQuery { barcode, language: ProductQuery.getLanguage(), country: ProductQuery.getCountry(), + fields: [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(); + } } }