|
@@ -52,6 +52,9 @@ class KemonoClient {
|
|
final response = await _dio.get(
|
|
final response = await _dio.get(
|
|
'/api/v1/$service/user/$creatorId/posts',
|
|
'/api/v1/$service/user/$creatorId/posts',
|
|
queryParameters: query.isEmpty ? {'o': start} : {'o':start, 'q': query},
|
|
queryParameters: query.isEmpty ? {'o': start} : {'o':start, 'q': query},
|
|
|
|
+ options: Options(
|
|
|
|
+ validateStatus: (status) => true,
|
|
|
|
+ ), // Accept all status codes
|
|
);
|
|
);
|
|
|
|
|
|
final parsedData = switch(response.data) {
|
|
final parsedData = switch(response.data) {
|
|
@@ -61,6 +64,11 @@ class KemonoClient {
|
|
_ => throw FormatException('Unprocessable data')
|
|
_ => throw FormatException('Unprocessable data')
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ if (parsedData is Map<String,dynamic> && (parsedData).containsKey("error"))
|
|
|
|
+ {
|
|
|
|
+ return List<Post>.empty();
|
|
|
|
+ }
|
|
|
|
+
|
|
return (parsedData as List).map((x) => Post.fromJson(x,_dio.options.baseUrl)).toList();
|
|
return (parsedData as List).map((x) => Post.fromJson(x,_dio.options.baseUrl)).toList();
|
|
} on DioException catch (e) {
|
|
} on DioException catch (e) {
|
|
throw Exception('Posts load failed: ${e.message} ${e.stackTrace}');
|
|
throw Exception('Posts load failed: ${e.message} ${e.stackTrace}');
|