1
0
mirror of https://github.com/go-vikunja/app synced 2024-06-01 02:06:51 +00:00

fixed disappearing lists on edit

This commit is contained in:
Benimautner 2022-08-26 17:38:32 +02:00
parent 57dd1d3e85
commit 1c163097d8
4 changed files with 12 additions and 12 deletions

View File

@ -13,6 +13,7 @@ class ListAPIService extends APIService implements ListService {
@override
Future<TaskList> create(namespaceId, TaskList tl) {
tl.namespaceId = namespaceId;
return client
.put('/namespaces/$namespaceId/lists', body: tl.toJSON())
.then((response) => TaskList.fromJson(response.body));

View File

@ -4,7 +4,8 @@ import 'package:vikunja_app/models/user.dart';
class TaskList {
final int id;
final String title, description;
int namespaceId;
String title, description;
final User owner;
final DateTime created, updated;
List<Task> tasks;
@ -12,13 +13,14 @@ class TaskList {
TaskList(
{@required this.id,
@required this.title,
this.description,
@required this.title,
this.owner,
this.created,
this.updated,
this.tasks,
this.isFavorite});
this.isFavorite,
this.namespaceId});
TaskList.fromJson(Map<String, dynamic> json)
: id = json['id'],
@ -28,6 +30,7 @@ class TaskList {
updated = DateTime.parse(json['updated']),
created = DateTime.parse(json['created']),
isFavorite = json['is_favorite'],
namespaceId = json['namespace_id'],
tasks = (json['tasks'] == null ? [] : json['tasks'] as List<dynamic>)
?.map((taskJson) => Task.fromJson(taskJson))
?.toList();
@ -40,6 +43,7 @@ class TaskList {
"owner": this.owner?.toJSON(),
"created": this.created?.toIso8601String(),
"updated": this.updated?.toIso8601String(),
"namespace_id": this.namespaceId
};
}
}

View File

@ -59,11 +59,7 @@ class _ListPageState extends State<ListPage> {
@override
void initState() {
_list = TaskList(
id: widget.taskList.id,
title: widget.taskList.title,
tasks: [],
);
_list = widget.taskList;
_keyboardController.onChange.listen((visible) {
if (!visible && mounted) FocusScope.of(context).unfocus();
});

View File

@ -136,10 +136,9 @@ class _ListEditPageState extends State<ListEditPage> {
setState(() => _loading = true);
// FIXME: is there a way we can update the list without creating a new list object?
// aka updating the existing list we got from context (setters?)
TaskList updatedList =
TaskList(id: widget.list.id, title: _title, description: _description);
VikunjaGlobal.of(context).listService.update(updatedList).then((_) {
widget.list.title = _title;
widget.list.description = _description;
VikunjaGlobal.of(context).listService.update(widget.list).then((_) {
setState(() => _loading = false);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('The list was updated successfully!'),