Use new list/sheets api instead of paged one

This commit is contained in:
2024-12-21 17:51:16 +01:00
parent 4651d2a5b0
commit 854528128f
3 changed files with 90 additions and 55 deletions

View File

@@ -121,15 +121,9 @@ class ApiClient {
return null;
}
Future<List<Sheet>> fetchSheets({String sortBy = "last_opened desc"}) async {
Future<List<Sheet>> fetchSheets() async {
try {
final bodyFormData = {
"page": 1,
"limit": "1000",
"sort_by": sortBy,
};
final response = await postFormData("/sheets", jsonEncode(bodyFormData));
final response = await get("/list/sheets");
if (response == null) {
return List.empty();
@@ -138,7 +132,7 @@ class ApiClient {
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
log("Data: $data");
return (data['rows'] as List<dynamic>)
return (data as List<dynamic>)
.map((sheet) => Sheet.fromJson(sheet as Map<String, dynamic>))
.toList();
} else {