Hotfix taksscheduling

main
Kai Mannweiler 2023-03-07 00:49:54 +01:00
parent cd0e44ab30
commit 575a2bb90e
4 changed files with 8 additions and 10 deletions

View File

@ -4,8 +4,8 @@ library app.globals;
import 'package:smoke_cess_app/mock/db_mock.dart'; import 'package:smoke_cess_app/mock/db_mock.dart';
import 'package:smoke_cess_app/services/database_service.dart'; import 'package:smoke_cess_app/services/database_service.dart';
DatabaseService databaseService = DatabaseService.instance; //DatabaseService databaseService = DatabaseService.instance;
//DatabaseService databaseService = DatabaseMock(); DatabaseService databaseService = DatabaseMock();
// set this to read settings from local json file instead of scanning a qr code // set this to read settings from local json file instead of scanning a qr code
bool useLocalConfig = true; bool useLocalConfig = true;

View File

@ -42,23 +42,21 @@ class TasksProvider extends ChangeNotifier {
void initTasks() async { void initTasks() async {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
TZDateTime? moodToday = await getTodayMood(); TZDateTime? moodToday = await getTodayMood();
if (moodToday != null) { if (moodToday != null && moodToday.isBefore(now)) {
List<Mood> moodList = await globals.databaseService.getMoodRecords(); List<Mood> moodList = await globals.databaseService.getMoodRecords();
if (moodList.isNotEmpty) { if (moodList.isNotEmpty) {
Mood mood = moodList.last; Mood mood = moodList.last;
tasks[Pages.mood] = tasks[Pages.mood] = !isSameDay(moodToday, mood.date);
!isSameDay(moodToday, mood.date) && moodToday.isBefore(now);
} }
} else { } else {
tasks[Pages.mood] = false; tasks[Pages.mood] = false;
} }
TZDateTime? sleepToday = await getTodaySleep(); TZDateTime? sleepToday = await getTodaySleep();
if (sleepToday != null) { if (sleepToday != null && sleepToday.isBefore(now)) {
List<Sleep> sleepList = await globals.databaseService.getSleepRecords(); List<Sleep> sleepList = await globals.databaseService.getSleepRecords();
if (sleepList.isNotEmpty) { if (sleepList.isNotEmpty) {
Sleep sleep = sleepList.last; Sleep sleep = sleepList.last;
tasks[Pages.sleep] = tasks[Pages.sleep] = !isSameDay(sleepToday, sleep.date);
!isSameDay(sleepToday, sleep.date) && sleepToday.isBefore(now);
} }
} else { } else {
tasks[Pages.sleep] = false; tasks[Pages.sleep] = false;

View File

@ -30,7 +30,7 @@ class RelapseForm extends StatelessWidget {
), ),
SubmitFormButton( SubmitFormButton(
submitCallback: inputModel.saveRelapse, submitCallback: inputModel.saveRelapse,
updateTasks: () => tasksModel.setTaskDone(Pages.mood), updateTasks: () => tasksModel.setTaskDone(Pages.relapse),
) )
], ],
); );

View File

@ -43,7 +43,7 @@ class SleepForm extends StatelessWidget {
SubmitFormButton( SubmitFormButton(
submitCallback: () => submitCallback: () =>
inputModel.saveSleep(SleepTimes.wokeUpAt, SleepTimes.sleptAt), inputModel.saveSleep(SleepTimes.wokeUpAt, SleepTimes.sleptAt),
updateTasks: () => tasksModel.setTaskDone(Pages.mood), updateTasks: () => tasksModel.setTaskDone(Pages.sleep),
) )
], ],
); );