Skip to content

Commit c190e1a

Browse files
fix: complete and delete task logic
1 parent 33a10cb commit c190e1a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lib/api_service.dart

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,24 @@ Future<void> updateTasksInDatabase(List<Tasks> tasks) async {
141141
localTask.status,
142142
localTask.uuid!,
143143
);
144+
if (localTask.status == 'completed') {
145+
completeTask('email', localTask.uuid!);
146+
} else if (localTask.status == 'deleted') {
147+
deleteTask('email', localTask.uuid!);
148+
}
144149
}
145150
}
146151
}
147152
}
148153

149-
Future<void> deleteTask(
150-
String email, String encryptionSecret, String uuid, String taskUuid) async {
154+
Future<void> deleteTask(String email, String taskUuid) async {
155+
var c = await CredentialsStorage.getClientId();
156+
var e = await CredentialsStorage.getEncryptionSecret();
151157
final url = Uri.parse('$baseUrl/delete-task');
152158
final body = jsonEncode({
153159
'email': email,
154-
'encryptionSecret': encryptionSecret,
155-
'UUID': uuid,
160+
'encryptionSecret': e,
161+
'UUID': c,
156162
'taskuuid': taskUuid,
157163
});
158164

@@ -175,13 +181,14 @@ Future<void> deleteTask(
175181
}
176182
}
177183

178-
Future<void> completeTask(
179-
String email, String encryptionSecret, String uuid, String taskUuid) async {
184+
Future<void> completeTask(String email, String taskUuid) async {
185+
var c = await CredentialsStorage.getClientId();
186+
var e = await CredentialsStorage.getEncryptionSecret();
180187
final url = Uri.parse('$baseUrl/complete-task');
181188
final body = jsonEncode({
182189
'email': email,
183-
'encryptionSecret': encryptionSecret,
184-
'UUID': uuid,
190+
'encryptionSecret': e,
191+
'UUID': c,
185192
'taskuuid': taskUuid,
186193
});
187194

lib/app/modules/home/views/show_tasks.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import 'package:taskwarrior/app/modules/home/views/show_details.dart';
88
import 'package:taskwarrior/app/utils/constants/palette.dart';
99
import 'package:taskwarrior/app/utils/constants/taskwarrior_colors.dart';
1010
import 'package:taskwarrior/app/utils/constants/taskwarrior_fonts.dart';
11-
import 'package:taskwarrior/app/utils/taskchampion/credentials_storage.dart';
1211
import 'package:taskwarrior/app/utils/theme/app_settings.dart';
1312

1413
class TaskViewBuilder extends StatelessWidget {
@@ -234,23 +233,17 @@ class TaskViewBuilder extends StatelessWidget {
234233
}
235234

236235
void _markTaskAsCompleted(String uuid) async {
237-
String clientId = (await CredentialsStorage.getClientId()) ?? '';
238-
String encryptionSecret =
239-
(await CredentialsStorage.getEncryptionSecret()) ?? '';
240236
TaskDatabase taskDatabase = TaskDatabase();
241237
await taskDatabase.open();
242238
taskDatabase.markTaskAsCompleted(uuid);
243-
completeTask('email', encryptionSecret, clientId, uuid);
239+
completeTask('email', uuid);
244240
}
245241

246242
void _markTaskAsDeleted(String uuid) async {
247-
String clientId = (await CredentialsStorage.getClientId()) ?? '';
248-
String encryptionSecret =
249-
(await CredentialsStorage.getEncryptionSecret()) ?? '';
250243
TaskDatabase taskDatabase = TaskDatabase();
251244
await taskDatabase.open();
252245
taskDatabase.markTaskAsDeleted(uuid);
253-
deleteTask('email', encryptionSecret, clientId, uuid);
246+
deleteTask('email', uuid);
254247
}
255248

256249
Color _getPriorityColor(String priority) {

0 commit comments

Comments
 (0)