Skip to content

Commit

Permalink
fix: complete and delete task logic
Browse files Browse the repository at this point in the history
  • Loading branch information
its-me-abhishek committed Jul 6, 2024
1 parent 33a10cb commit c190e1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
23 changes: 15 additions & 8 deletions lib/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,24 @@ Future<void> updateTasksInDatabase(List<Tasks> tasks) async {
localTask.status,
localTask.uuid!,
);
if (localTask.status == 'completed') {
completeTask('email', localTask.uuid!);
} else if (localTask.status == 'deleted') {
deleteTask('email', localTask.uuid!);
}
}
}
}
}

Future<void> deleteTask(
String email, String encryptionSecret, String uuid, String taskUuid) async {
Future<void> deleteTask(String email, String taskUuid) async {
var c = await CredentialsStorage.getClientId();
var e = await CredentialsStorage.getEncryptionSecret();
final url = Uri.parse('$baseUrl/delete-task');
final body = jsonEncode({
'email': email,
'encryptionSecret': encryptionSecret,
'UUID': uuid,
'encryptionSecret': e,
'UUID': c,
'taskuuid': taskUuid,
});

Expand All @@ -175,13 +181,14 @@ Future<void> deleteTask(
}
}

Future<void> completeTask(
String email, String encryptionSecret, String uuid, String taskUuid) async {
Future<void> completeTask(String email, String taskUuid) async {
var c = await CredentialsStorage.getClientId();
var e = await CredentialsStorage.getEncryptionSecret();
final url = Uri.parse('$baseUrl/complete-task');
final body = jsonEncode({
'email': email,
'encryptionSecret': encryptionSecret,
'UUID': uuid,
'encryptionSecret': e,
'UUID': c,
'taskuuid': taskUuid,
});

Expand Down
11 changes: 2 additions & 9 deletions lib/app/modules/home/views/show_tasks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:taskwarrior/app/modules/home/views/show_details.dart';
import 'package:taskwarrior/app/utils/constants/palette.dart';
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart';
import 'package:taskwarrior/app/utils/taskchampion/credentials_storage.dart';
import 'package:taskwarrior/app/utils/theme/app_settings.dart';

class TaskViewBuilder extends StatelessWidget {
Expand Down Expand Up @@ -234,23 +233,17 @@ class TaskViewBuilder extends StatelessWidget {
}

void _markTaskAsCompleted(String uuid) async {
String clientId = (await CredentialsStorage.getClientId()) ?? '';
String encryptionSecret =
(await CredentialsStorage.getEncryptionSecret()) ?? '';
TaskDatabase taskDatabase = TaskDatabase();
await taskDatabase.open();
taskDatabase.markTaskAsCompleted(uuid);
completeTask('email', encryptionSecret, clientId, uuid);
completeTask('email', uuid);
}

void _markTaskAsDeleted(String uuid) async {
String clientId = (await CredentialsStorage.getClientId()) ?? '';
String encryptionSecret =
(await CredentialsStorage.getEncryptionSecret()) ?? '';
TaskDatabase taskDatabase = TaskDatabase();
await taskDatabase.open();
taskDatabase.markTaskAsDeleted(uuid);
deleteTask('email', encryptionSecret, clientId, uuid);
deleteTask('email', uuid);
}

Color _getPriorityColor(String priority) {
Expand Down

0 comments on commit c190e1a

Please sign in to comment.