mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-12 19:33:41 +00:00
feat(task): record and display task completion time
Add DoneAt to the download task model: set when a task finishes and cleared when it is downloaded again. The value flows through the API model and task record, and is shown as "Completed at" in the task drawer info tab next to the creation time.
This commit is contained in:
1 parent
694b43e3f9
commit
4b231f52c5
30 files changed
+82
-23
No files matched your search
@@ -4,7 +4,7 @@ import 'package:gopeed/core/icons/gopeed_icons.dart';
|
||||
import 'package:gopeed/features/tasks/domain/task_record.dart';
|
||||
|
||||
void main() {
|
||||
api.Task buildTask(List<int> selection, int size) => api.Task.fromJson({
|
||||
api.Task buildTask(List<int> selection, int size, {String? doneAt}) => api.Task.fromJson({
|
||||
'id': 'bt-selection',
|
||||
'name': 'bundle',
|
||||
'protocol': 'bt',
|
||||
@@ -12,6 +12,7 @@ void main() {
|
||||
'uploading': false,
|
||||
'createdAt': '2026-01-01T00:00:00Z',
|
||||
'updatedAt': '2026-01-01T00:00:00Z',
|
||||
'doneAt': doneAt,
|
||||
'meta': {
|
||||
'req': {'url': 'magnet:?xt=urn:btih:test'},
|
||||
'opts': {'path': '/downloads', 'selectFiles': selection},
|
||||
@@ -43,6 +44,13 @@ void main() {
|
||||
expect(record.totalBytes, 60);
|
||||
});
|
||||
|
||||
test('completion time maps from api and stays null for legacy tasks', () {
|
||||
final completed = TaskRecord.fromApi(buildTask([], 60, doneAt: '2026-01-02T03:04:05Z'));
|
||||
expect(completed.doneAt, DateTime.parse('2026-01-02T03:04:05Z'));
|
||||
final legacy = TaskRecord.fromApi(buildTask([], 60));
|
||||
expect(legacy.doneAt, isNull);
|
||||
});
|
||||
|
||||
test('file names preserve hash and question mark characters for type detection', () {
|
||||
expect(
|
||||
taskFileTypeIcon('Slow English Podcast #2 _ Eating, Talking, and Learning Natural English.mp4'),
|
||||
|
||||
Reference in new issue
Block a user