From 95f75315b97af368cbc0ce49cf9b1582cb51a55a Mon Sep 17 00:00:00 2001 From: nhathiwala Date: Mon, 18 Mar 2019 01:33:39 +0530 Subject: [PATCH] ## [0.1.4+3] - Improve library health. - [Bug] Solved few health suggestion, to improve the health of the code. --- CHANGELOG.md | 3 +++ lib/src/algolia.dart | 2 +- lib/src/index_reference.dart | 4 ++-- lib/src/query_snapshot.dart | 4 ++-- pubspec.yaml | 2 +- test/algolia_test.dart | 12 ++---------- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b59ea62..08b9b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.1.4+3] - Improve library health. +- [Bug] Solved few health suggestion, to improve the health of the code. + ## [0.1.4+2] - Added few advance query references and solved bugs. - [Bug] `.setFacetFilter(dynamic value)` can now accept String or List value. - [Added] AttributeForDistinct (Advance) diff --git a/lib/src/algolia.dart b/lib/src/algolia.dart index 4941720..9035f8f 100644 --- a/lib/src/algolia.dart +++ b/lib/src/algolia.dart @@ -68,7 +68,7 @@ class Algolia { print(body); return AlgoliaIndexesSnapshot._(this, body); } catch (err) { - throw err; + return err; } } } diff --git a/lib/src/index_reference.dart b/lib/src/index_reference.dart index 313a6c0..a0bf018 100644 --- a/lib/src/index_reference.dart +++ b/lib/src/index_reference.dart @@ -99,7 +99,7 @@ class AlgoliaIndexReference extends AlgoliaQuery { Map body = json.decode(response.body); return AlgoliaTask._(algolia, index, body); } catch (err) { - throw err; + return err; } } @@ -119,7 +119,7 @@ class AlgoliaIndexReference extends AlgoliaQuery { Map body = json.decode(response.body); return AlgoliaTask._(algolia, index, body); } catch (err) { - throw err; + return err; } } } diff --git a/lib/src/query_snapshot.dart b/lib/src/query_snapshot.dart index 6765c19..35c35e0 100644 --- a/lib/src/query_snapshot.dart +++ b/lib/src/query_snapshot.dart @@ -39,7 +39,7 @@ class AlgoliaQuerySnapshot { .toList() .cast(); this.hits = hitsReMap; - this.empty = this.hits.length == 0; + this.empty = this.hits.isEmpty; this.nbHits = map['nbHits']; this.page = map['page']; this.nbPages = map['nbPages']; @@ -48,6 +48,6 @@ class AlgoliaQuerySnapshot { this.exhaustiveNbHits = map['exhaustiveNbHits']; this.query = map['query']; this.params = map['params']; - this.facets = map['facets'] != null ? map['facets'] : {}; + this.facets = map['facets'] != null ? map['facets'] : {}; } } diff --git a/pubspec.yaml b/pubspec.yaml index d841c12..57fa65d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: algolia -version: 0.1.4+2 +version: 0.1.4+3 authors: - Nayan Hathiwala (Knoxpo) description: > diff --git a/test/algolia_test.dart b/test/algolia_test.dart index 0ad519e7..3c29298 100644 --- a/test/algolia_test.dart +++ b/test/algolia_test.dart @@ -204,17 +204,9 @@ void main() async { }); } -// class Application { -// static final Algolia algolia = Algolia.init( -// applicationId: 'YOUR_APPLICATION_ID', -// apiKey: 'YOUR_API_KEY', -// ); -// } - - class Application { static final Algolia algolia = Algolia.init( - applicationId: '86BGVLXUEM', - apiKey: '07e1fdc2794cc6dabefd9219e83acd1d', + applicationId: 'YOUR_APPLICATION_ID', + apiKey: 'YOUR_API_KEY', ); } \ No newline at end of file