Skip to content

Commit d802b00

Browse files
authored
fix(detail): avoid backend auto-start; save user-selected start only
PR #517
1 parent 2ab4322 commit d802b00

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

lib/app/modules/detailRoute/controllers/detail_route_controller.dart

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class DetailRouteController extends GetxController {
1717
var onEdit = false.obs;
1818
var isReadOnly = false.obs;
1919

20+
// Track whether user explicitly selected a start date
21+
bool startEdited = false;
22+
2023
@override
2124
void onInit() {
2225
super.onInit();
@@ -50,13 +53,19 @@ class DetailRouteController extends GetxController {
5053
}
5154

5255
if (name == 'start') {
53-
debugPrint('Start Value Changed to $newValue');
56+
startEdited = true; // MARK AS USER-SELECTED
5457
startValue.value = newValue;
5558
}
5659
initValues();
5760
}
5861

5962
Future<void> saveChanges() async {
63+
// If start was never edited AND backend auto-generated it (start == entry)
64+
if (!startEdited &&
65+
modify.original.start != null &&
66+
modify.original.start!.isAtSameMomentAs(modify.original.entry)) {
67+
modify.set('start', null); // remove auto start
68+
}
6069
var now = DateTime.now().toUtc();
6170
modify.save(modified: () => now);
6271
onEdit.value = false;
@@ -106,7 +115,20 @@ class DetailRouteController extends GetxController {
106115
statusValue.value = modify.draft.status;
107116
entryValue.value = modify.draft.entry;
108117
modifiedValue.value = modify.draft.modified;
109-
startValue.value ??= null;
118+
final originalStart = modify.original.start;
119+
final originalEntry = modify.original.entry;
120+
121+
final backendAutoStart = (originalStart != null &&
122+
originalStart.isAtSameMomentAs(originalEntry));
123+
124+
// START DATE LOGIC (THE FIX)
125+
if (startEdited) {
126+
startValue.value = modify.draft.start;
127+
} else if (backendAutoStart) {
128+
startValue.value = null; // Do not show backend auto start
129+
} else {
130+
startValue.value = modify.draft.start; // Existing meaningful start
131+
}
110132
endValue.value = modify.draft.end;
111133
dueValue.value = modify.draft.due;
112134
waitValue.value = modify.draft.wait;
@@ -148,15 +170,7 @@ class DetailRouteController extends GetxController {
148170
const Duration(milliseconds: 500),
149171
() {
150172
SaveTourStatus.getDetailsTourStatus().then((value) => {
151-
if (value == false)
152-
{
153-
tutorialCoachMark.show(context: context),
154-
}
155-
else
156-
{
157-
// ignore: avoid_print
158-
print('User has seen this page'),
159-
}
173+
if (!value) {tutorialCoachMark.show(context: context)}
160174
});
161175
},
162176
);

lib/app/utils/taskfunctions/draft.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'package:taskwarrior/app/models/models.dart';
32
import 'package:taskwarrior/app/utils/taskfunctions/patch.dart';
43

lib/app/utils/taskfunctions/modify.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Modify {
2222

2323
Task get draft => _draft.draft;
2424
int get id => _draft.original.id!;
25+
Task get original => _draft.original;
2526

2627
Map<dynamic, Map> get changes {
2728
var result = <dynamic, Map>{};

0 commit comments

Comments
 (0)