Skip to content

Commit

Permalink
added server recommendations
Browse files Browse the repository at this point in the history
made listId optional
  • Loading branch information
Benimautner committed May 12, 2023
1 parent 77a1e8c commit 882bf55
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 92 deletions.
6 changes: 3 additions & 3 deletions lib/api/list_implementation.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:developer';

import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:vikunja_app/api/client.dart';
Expand Down Expand Up @@ -48,9 +47,10 @@ class ListAPIService extends APIService implements ListService {
Future<List<TaskList>?> getAll() {
return client.get('/lists').then(
(list) {
if (list == null) return null;
if (list == null || list.statusCode != 200) return null;
if (list.body.toString().isEmpty)
return Future.value([]);
print(list.statusCode);
return convertList(list.body, (result) => TaskList.fromJson(result));});
}

Expand All @@ -66,7 +66,7 @@ class ListAPIService extends APIService implements ListService {
}
return client.get('/namespaces/$namespaceId/lists').then(
(list) {
if (list == null) return null;
if (list == null || list.statusCode != 200) return null;
return convertList(list.body, (result) => TaskList.fromJson(result));
});
}
Expand Down
13 changes: 7 additions & 6 deletions lib/global.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:developer' as dev;

import 'package:flutter/material.dart';
import 'package:flutter_timezone/flutter_timezone.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:vikunja_app/api/bucket_implementation.dart';
import 'package:vikunja_app/api/client.dart';
Expand All @@ -19,7 +18,6 @@ import 'package:vikunja_app/managers/user.dart';
import 'package:vikunja_app/models/user.dart';
import 'package:vikunja_app/service/services.dart';
import 'package:timezone/data/latest_all.dart' as tz;
import 'package:flutter_local_notifications/flutter_local_notifications.dart'as notifs;
import 'package:workmanager/workmanager.dart';


Expand Down Expand Up @@ -147,18 +145,21 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
}


void logoutUser(BuildContext context) {
_storage.deleteAll().then((_) {
void logoutUser(BuildContext context) async {
// _storage.deleteAll().then((_) {
var userId = await _storage.read(key: "currentUser");
_storage.delete(key: userId!); //delete token
_storage.delete(key: "${userId}_base");
Navigator.pop(context);
setState(() {
client.reset();
_currentUser = null;
});
}).catchError((err) {
/* }).catchError((err) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('An error occured while logging out!'),
));
});
});*/
}

void _loadCurrentUser() async {
Expand Down
2 changes: 1 addition & 1 deletion lib/models/task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:vikunja_app/utils/checkboxes_in_text.dart';
class Task {
final int id;
final int? parentTaskId, priority, bucketId;
final int listId;
final int? listId;
final DateTime created, updated;
DateTime? dueDate, startDate, endDate;
final List<DateTime> reminderDates;
Expand Down
Loading

0 comments on commit 882bf55

Please sign in to comment.