fix calendar persistence
This commit is contained in:
Vendored
+5
-3
@@ -2186,13 +2186,15 @@
|
|||||||
// src/Views/Objects/calendarView.tsx
|
// src/Views/Objects/calendarView.tsx
|
||||||
function CalendarView(chat, messageObjects, selectedObject, isShowingObjectModal) {
|
function CalendarView(chat, messageObjects, selectedObject, isShowingObjectModal) {
|
||||||
const selectedDate = new Date(dayInCalendar.value);
|
const selectedDate = new Date(dayInCalendar.value);
|
||||||
const selectedMonth = new State(selectedDate.getMonth());
|
const selectedMonth = new State(selectedDate.getMonth() + 1);
|
||||||
const selectedYear = new State(selectedDate.getFullYear());
|
const selectedYear = new State(selectedDate.getFullYear());
|
||||||
bulkSubscribe([selectedMonth, selectedYear], () => {
|
bulkSubscribe([selectedMonth, selectedYear], () => updateSelectedDate());
|
||||||
|
updateSelectedDate();
|
||||||
|
function updateSelectedDate() {
|
||||||
selectedDate.setMonth(selectedMonth.value - 1);
|
selectedDate.setMonth(selectedMonth.value - 1);
|
||||||
selectedDate.setFullYear(selectedYear.value);
|
selectedDate.setFullYear(selectedYear.value);
|
||||||
dayInCalendar.value = selectedDate.toISOString().split("T")[0];
|
dayInCalendar.value = selectedDate.toISOString().split("T")[0];
|
||||||
});
|
}
|
||||||
function previousMonth() {
|
function previousMonth() {
|
||||||
if (selectedMonth.value <= 1) {
|
if (selectedMonth.value <= 1) {
|
||||||
selectedMonth.value = 12;
|
selectedMonth.value = 12;
|
||||||
|
|||||||
@@ -14,14 +14,17 @@ export function CalendarView(
|
|||||||
isShowingObjectModal: React.State<boolean>
|
isShowingObjectModal: React.State<boolean>
|
||||||
) {
|
) {
|
||||||
const selectedDate = new Date(dayInCalendar.value);
|
const selectedDate = new Date(dayInCalendar.value);
|
||||||
const selectedMonth = new React.State(selectedDate.getMonth());
|
const selectedMonth = new React.State(selectedDate.getMonth() + 1);
|
||||||
const selectedYear = new React.State(selectedDate.getFullYear());
|
const selectedYear = new React.State(selectedDate.getFullYear());
|
||||||
|
|
||||||
React.bulkSubscribe([selectedMonth, selectedYear], () => {
|
React.bulkSubscribe([selectedMonth, selectedYear], () => updateSelectedDate());
|
||||||
|
updateSelectedDate();
|
||||||
|
|
||||||
|
function updateSelectedDate() {
|
||||||
selectedDate.setMonth(selectedMonth.value - 1);
|
selectedDate.setMonth(selectedMonth.value - 1);
|
||||||
selectedDate.setFullYear(selectedYear.value);
|
selectedDate.setFullYear(selectedYear.value);
|
||||||
dayInCalendar.value = selectedDate.toISOString().split("T")[0];
|
dayInCalendar.value = selectedDate.toISOString().split("T")[0];
|
||||||
});
|
}
|
||||||
|
|
||||||
function previousMonth() {
|
function previousMonth() {
|
||||||
if (selectedMonth.value <= 1) {
|
if (selectedMonth.value <= 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user