Skip to content

Commit 882bf55

Browse files
committed
added server recommendations
made listId optional
1 parent 77a1e8c commit 882bf55

File tree

5 files changed

+203
-92
lines changed

5 files changed

+203
-92
lines changed

lib/api/list_implementation.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:async';
2-
import 'dart:developer';
32

43
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
54
import 'package:vikunja_app/api/client.dart';
@@ -48,9 +47,10 @@ class ListAPIService extends APIService implements ListService {
4847
Future<List<TaskList>?> getAll() {
4948
return client.get('/lists').then(
5049
(list) {
51-
if (list == null) return null;
50+
if (list == null || list.statusCode != 200) return null;
5251
if (list.body.toString().isEmpty)
5352
return Future.value([]);
53+
print(list.statusCode);
5454
return convertList(list.body, (result) => TaskList.fromJson(result));});
5555
}
5656

@@ -66,7 +66,7 @@ class ListAPIService extends APIService implements ListService {
6666
}
6767
return client.get('/namespaces/$namespaceId/lists').then(
6868
(list) {
69-
if (list == null) return null;
69+
if (list == null || list.statusCode != 200) return null;
7070
return convertList(list.body, (result) => TaskList.fromJson(result));
7171
});
7272
}

lib/global.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:developer' as dev;
22

33
import 'package:flutter/material.dart';
4-
import 'package:flutter_timezone/flutter_timezone.dart';
54
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
65
import 'package:vikunja_app/api/bucket_implementation.dart';
76
import 'package:vikunja_app/api/client.dart';
@@ -19,7 +18,6 @@ import 'package:vikunja_app/managers/user.dart';
1918
import 'package:vikunja_app/models/user.dart';
2019
import 'package:vikunja_app/service/services.dart';
2120
import 'package:timezone/data/latest_all.dart' as tz;
22-
import 'package:flutter_local_notifications/flutter_local_notifications.dart'as notifs;
2321
import 'package:workmanager/workmanager.dart';
2422

2523

@@ -147,18 +145,21 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
147145
}
148146

149147

150-
void logoutUser(BuildContext context) {
151-
_storage.deleteAll().then((_) {
148+
void logoutUser(BuildContext context) async {
149+
// _storage.deleteAll().then((_) {
150+
var userId = await _storage.read(key: "currentUser");
151+
_storage.delete(key: userId!); //delete token
152+
_storage.delete(key: "${userId}_base");
152153
Navigator.pop(context);
153154
setState(() {
154155
client.reset();
155156
_currentUser = null;
156157
});
157-
}).catchError((err) {
158+
/* }).catchError((err) {
158159
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
159160
content: Text('An error occured while logging out!'),
160161
));
161-
});
162+
});*/
162163
}
163164

164165
void _loadCurrentUser() async {

lib/models/task.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:vikunja_app/utils/checkboxes_in_text.dart';
1010
class Task {
1111
final int id;
1212
final int? parentTaskId, priority, bucketId;
13-
final int listId;
13+
final int? listId;
1414
final DateTime created, updated;
1515
DateTime? dueDate, startDate, endDate;
1616
final List<DateTime> reminderDates;

0 commit comments

Comments
 (0)