From fda962a46f2700a67f07a6c73bb43f3cf50115a4 Mon Sep 17 00:00:00 2001 From: Naveen jangra Date: Sat, 12 Oct 2024 15:52:04 +0530 Subject: [PATCH] git commit -m 'trending page is not working due to open lib not responding :FIXED' --- lib/services/open_library.dart | 27 +++++++++++++++------------ lib/state/state.dart | 7 +++++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/services/open_library.dart b/lib/services/open_library.dart index c299ad2..065799e 100644 --- a/lib/services/open_library.dart +++ b/lib/services/open_library.dart @@ -46,10 +46,11 @@ class OpenLibrary { receiveTimeout: const Duration(seconds: 20))); return _parser('${response.data.toString()}${response2.data.toString()}'); } on DioException catch (e) { - if (e.type == DioExceptionType.unknown) { - throw "socketException"; - } - rethrow; + return []; + // if (e.type == DioExceptionType.unknown) { + // throw "socketException"; + // } + // rethrow; } } } @@ -94,10 +95,11 @@ class GoodReads { receiveTimeout: const Duration(seconds: 20))); return _parser(response.data.toString()); } on DioException catch (e) { - if (e.type == DioExceptionType.unknown) { - throw "socketException"; - } - rethrow; + return []; + // if (e.type == DioExceptionType.unknown) { + // throw "socketException"; + // } + // rethrow; } } } @@ -142,10 +144,11 @@ class PenguinRandomHouse { receiveTimeout: const Duration(seconds: 20))); return _parser(response.data.toString()); } on DioException catch (e) { - if (e.type == DioExceptionType.unknown) { - throw "socketException"; - } - rethrow; + return []; + // if (e.type == DioExceptionType.unknown) { + // throw "socketException"; + // } + // rethrow; } } } diff --git a/lib/state/state.dart b/lib/state/state.dart index 6ef6979..91da014 100644 --- a/lib/state/state.dart +++ b/lib/state/state.dart @@ -77,12 +77,15 @@ final getTrendingBooks = FutureProvider>((ref) async { PenguinRandomHouse penguinTrending = PenguinRandomHouse(); List trendingBooks = await Future.wait>([ - openLibrary.trendingBooks(), goodReads.trendingBooks(), - penguinTrending.trendingBooks() + penguinTrending.trendingBooks(), + openLibrary.trendingBooks(), ]).then((List> listOfData) => listOfData.expand((element) => element).toList()); + if(trendingBooks.isEmpty){ + throw 'Nothing Trending Today :('; + } trendingBooks.shuffle(); return trendingBooks; });