mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 01:50:30 +00:00
feat: support browse files on web (#283)
This commit is contained in:
14 files changed
+145
-71
No files matched your search
@@ -1,8 +1,7 @@
|
||||
|
||||
import 'package:gopeed/app/modules/task/controllers/task_list_controller.dart';
|
||||
|
||||
import '../../../../api/model/task.dart';
|
||||
|
||||
class TaskDownloadedController extends TaskListController {
|
||||
TaskDownloadedController() : super([Status.done]);
|
||||
TaskDownloadedController() : super([Status.done], SortDirection.asc);
|
||||
}
|
||||
@@ -9,5 +9,5 @@ class TaskDownloadingController extends TaskListController {
|
||||
Status.pause,
|
||||
Status.wait,
|
||||
Status.error
|
||||
]);
|
||||
], SortDirection.desc);
|
||||
}
|
||||
@@ -5,10 +5,13 @@ import 'package:get/get.dart';
|
||||
import '../../../../api/api.dart';
|
||||
import '../../../../api/model/task.dart';
|
||||
|
||||
enum SortDirection { asc, desc }
|
||||
|
||||
abstract class TaskListController extends GetxController {
|
||||
List<Status> statuses;
|
||||
SortDirection sortDirection;
|
||||
|
||||
TaskListController(this.statuses);
|
||||
TaskListController(this.statuses, this.sortDirection);
|
||||
|
||||
final tasks = <Task>[].obs;
|
||||
final isRunning = false.obs;
|
||||
@@ -43,6 +46,15 @@ abstract class TaskListController extends GetxController {
|
||||
}
|
||||
|
||||
getTasksState() async {
|
||||
tasks.value = await getTasks(statuses);
|
||||
final tasks = await getTasks(statuses);
|
||||
// sort tasks by create time
|
||||
tasks.sort((a, b) {
|
||||
if (sortDirection == SortDirection.asc) {
|
||||
return a.createdAt.compareTo(b.createdAt);
|
||||
} else {
|
||||
return b.createdAt.compareTo(a.createdAt);
|
||||
}
|
||||
});
|
||||
this.tasks.value = tasks;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user