1
0
mirror of https://github.com/go-vikunja/app synced 2024-06-14 08:24:18 +00:00

fixed error with favourite lists.

This commit is contained in:
benimautner 2022-04-12 23:27:14 +02:00
parent 059f36c828
commit 2dfe99b51b
2 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:vikunja_app/api/client.dart';
@ -41,6 +42,12 @@ class ListAPIService extends APIService implements ListService {
@override
Future<List<TaskList>> getByNamespace(int namespaceId) {
// TODO there needs to be a better way for this. /namespaces/-2/lists should
// return favorite lists
if(namespaceId == -2) {
// Favourites.
return getAll().then((value) {value.removeWhere((element) => !element.isFavorite); return value;});
}
return client.get('/namespaces/$namespaceId/lists').then(
(list) => convertList(list, (result) => TaskList.fromJson(result)));
}

View File

@ -8,6 +8,7 @@ class TaskList {
final User owner;
final DateTime created, updated;
final List<Task> tasks;
final bool isFavorite;
TaskList(
{@required this.id,
@ -16,7 +17,8 @@ class TaskList {
this.owner,
this.created,
this.updated,
this.tasks});
this.tasks,
this.isFavorite});
TaskList.fromJson(Map<String, dynamic> json)
: id = json['id'],
@ -25,6 +27,7 @@ class TaskList {
title = json['title'],
updated = DateTime.parse(json['updated']),
created = DateTime.parse(json['created']),
isFavorite = json['is_favorite'],
tasks = (json['tasks'] == null ? [] : json['tasks'] as List<dynamic>)
?.map((taskJson) => Task.fromJson(taskJson))
?.toList();