Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/api_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ignore_for_file: depend_on_referenced_packages, unnecessary_null_in_if_null_operators

import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
Expand Down Expand Up @@ -205,6 +205,11 @@ Future<void> completeTask(String email, String taskUuid) async {
debugPrint('Task completed successfully on server');
} else {
debugPrint('Failed to complete task: ${response.statusCode}');
ScaffoldMessenger.of(context as BuildContext).showSnackBar(const SnackBar(
content: Text(
"Failed to complete task!",
style: TextStyle(color: Colors.red),
)));
}
} catch (e) {
debugPrint('Error completing task: $e');
Expand Down Expand Up @@ -250,7 +255,7 @@ Future<void> modifyTaskOnTaskwarrior(String description, String project,
var e = await CredentialsStorage.getEncryptionSecret();
debugPrint(c);
debugPrint(e);
await http.post(
final response = await http.post(
Uri.parse(apiUrl),
headers: {
'Content-Type': 'text/plain',
Expand All @@ -268,6 +273,14 @@ Future<void> modifyTaskOnTaskwarrior(String description, String project,
}),
);

if (response.statusCode != 200) {
ScaffoldMessenger.of(context as BuildContext).showSnackBar(const SnackBar(
content: Text(
"Failed to update task!",
style: TextStyle(color: Colors.red),
)));
}

var taskDatabase = TaskDatabase();
await taskDatabase.open();
await taskDatabase._database!.delete(
Expand Down
Loading