add chron to coreVM

This commit is contained in:
marlon-erler
2026-04-16 11:56:42 +00:00
parent 75faa40797
commit cae717066a
5 changed files with 96 additions and 10 deletions
+18 -1
View File
@@ -28,6 +28,7 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
};
// state
currentTodayDate: string | undefined = undefined;
selectedYear: React.State<number> = new React.State(0);
selectedMonth: React.State<number> = new React.State(0);
selectedDate: React.State<number> = new React.State(0);
@@ -121,7 +122,7 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
};
showToday = (): void => {
const today: Date = new Date();
const today: Date = this.coreViewModel.todayDate.value;
this.selectedYear.value = today.getFullYear();
this.selectedMonth.value = today.getMonth() + 1;
this.selectedDate.value = today.getDate();
@@ -158,9 +159,21 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
draggedObject.setDate(ISOString);
};
updateMonthGrid = (): void => {
if (
this.currentTodayDate ==
this.coreViewModel.todayDate.value.toISOString()
)
return;
this.loadMonthTasks();
this.currentTodayDate =
this.coreViewModel.todayDate.value.toISOString();
};
// load
loadMonthTasks = (): void => {
this.monthGrid.value = this.calendarModel.generateMonthGrid(
this.coreViewModel,
this.selectedYear.value,
this.selectedMonth.value,
() => new React.MapState(),
@@ -206,6 +219,10 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
this.showTask(taskFileContent);
},
);
this.coreViewModel.chronHandlerManager.setHandler(
`calendar-${this.chatViewModel.chatModel.id}`,
this.updateMonthGrid,
);
// initiate
this.showToday();