Merge pull request #119 from Nav-jangra/trending

trending page error
This commit is contained in:
dstark5
2024-10-13 18:00:06 +05:30
committed by GitHub
2 changed files with 20 additions and 14 deletions

View File

@ -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;
}
}
}

View File

@ -77,12 +77,15 @@ final getTrendingBooks = FutureProvider<List<TrendingBookData>>((ref) async {
PenguinRandomHouse penguinTrending = PenguinRandomHouse();
List<TrendingBookData> trendingBooks =
await Future.wait<List<TrendingBookData>>([
openLibrary.trendingBooks(),
goodReads.trendingBooks(),
penguinTrending.trendingBooks()
penguinTrending.trendingBooks(),
openLibrary.trendingBooks(),
]).then((List<List<TrendingBookData>> listOfData) =>
listOfData.expand((element) => element).toList());
if(trendingBooks.isEmpty){
throw 'Nothing Trending Today :(';
}
trendingBooks.shuffle();
return trendingBooks;
});