Hotfix taksscheduling
parent
cd0e44ab30
commit
575a2bb90e
|
@ -4,8 +4,8 @@ library app.globals;
|
|||
import 'package:smoke_cess_app/mock/db_mock.dart';
|
||||
import 'package:smoke_cess_app/services/database_service.dart';
|
||||
|
||||
DatabaseService databaseService = DatabaseService.instance;
|
||||
//DatabaseService databaseService = DatabaseMock();
|
||||
//DatabaseService databaseService = DatabaseService.instance;
|
||||
DatabaseService databaseService = DatabaseMock();
|
||||
|
||||
// set this to read settings from local json file instead of scanning a qr code
|
||||
bool useLocalConfig = true;
|
||||
|
|
|
@ -42,23 +42,21 @@ class TasksProvider extends ChangeNotifier {
|
|||
void initTasks() async {
|
||||
DateTime now = DateTime.now();
|
||||
TZDateTime? moodToday = await getTodayMood();
|
||||
if (moodToday != null) {
|
||||
if (moodToday != null && moodToday.isBefore(now)) {
|
||||
List<Mood> moodList = await globals.databaseService.getMoodRecords();
|
||||
if (moodList.isNotEmpty) {
|
||||
Mood mood = moodList.last;
|
||||
tasks[Pages.mood] =
|
||||
!isSameDay(moodToday, mood.date) && moodToday.isBefore(now);
|
||||
tasks[Pages.mood] = !isSameDay(moodToday, mood.date);
|
||||
}
|
||||
} else {
|
||||
tasks[Pages.mood] = false;
|
||||
}
|
||||
TZDateTime? sleepToday = await getTodaySleep();
|
||||
if (sleepToday != null) {
|
||||
if (sleepToday != null && sleepToday.isBefore(now)) {
|
||||
List<Sleep> sleepList = await globals.databaseService.getSleepRecords();
|
||||
if (sleepList.isNotEmpty) {
|
||||
Sleep sleep = sleepList.last;
|
||||
tasks[Pages.sleep] =
|
||||
!isSameDay(sleepToday, sleep.date) && sleepToday.isBefore(now);
|
||||
tasks[Pages.sleep] = !isSameDay(sleepToday, sleep.date);
|
||||
}
|
||||
} else {
|
||||
tasks[Pages.sleep] = false;
|
||||
|
|
|
@ -30,7 +30,7 @@ class RelapseForm extends StatelessWidget {
|
|||
),
|
||||
SubmitFormButton(
|
||||
submitCallback: inputModel.saveRelapse,
|
||||
updateTasks: () => tasksModel.setTaskDone(Pages.mood),
|
||||
updateTasks: () => tasksModel.setTaskDone(Pages.relapse),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
|
|
@ -43,7 +43,7 @@ class SleepForm extends StatelessWidget {
|
|||
SubmitFormButton(
|
||||
submitCallback: () =>
|
||||
inputModel.saveSleep(SleepTimes.wokeUpAt, SleepTimes.sleptAt),
|
||||
updateTasks: () => tasksModel.setTaskDone(Pages.mood),
|
||||
updateTasks: () => tasksModel.setTaskDone(Pages.sleep),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue