mirror of
https://github.com/callumalpass/tasknotes.git
synced 2026-07-22 12:50:26 +00:00
fix: Resolve undefined days display in custom calendar view
- Add fallback values (|| 3) to customDayCount in calendar configuration - Enhance settings loading to deep merge calendarViewSettings with defaults - Add detection for new calendar settings to trigger automatic migration - Ensure custom view button shows proper day count on first load Fixes issue where custom calendar view displayed "undefined days" until user manually adjusted day count setting.
This commit is contained in:
parent
c74fe54833
commit
6b5d8105ae
2 changed files with 15 additions and 7 deletions
14
src/main.ts
14
src/main.ts
|
|
@ -787,15 +787,23 @@ export default class TaskNotesPlugin extends Plugin {
|
|||
// Deep merge custom statuses array
|
||||
customStatuses: loadedData?.customStatuses || DEFAULT_SETTINGS.customStatuses,
|
||||
// Deep merge custom priorities array
|
||||
customPriorities: loadedData?.customPriorities || DEFAULT_SETTINGS.customPriorities
|
||||
customPriorities: loadedData?.customPriorities || DEFAULT_SETTINGS.customPriorities,
|
||||
// Deep merge calendar view settings to ensure new fields get default values
|
||||
calendarViewSettings: {
|
||||
...DEFAULT_SETTINGS.calendarViewSettings,
|
||||
...(loadedData?.calendarViewSettings || {})
|
||||
}
|
||||
};
|
||||
|
||||
// Check if we added any new field mappings and save if needed
|
||||
// Check if we added any new field mappings or calendar settings and save if needed
|
||||
const hasNewFields = Object.keys(DEFAULT_SETTINGS.fieldMapping).some(key =>
|
||||
!(loadedData?.fieldMapping?.[key])
|
||||
);
|
||||
const hasNewCalendarSettings = Object.keys(DEFAULT_SETTINGS.calendarViewSettings).some(key =>
|
||||
!(loadedData?.calendarViewSettings?.[key as keyof typeof DEFAULT_SETTINGS.calendarViewSettings])
|
||||
);
|
||||
|
||||
if (hasNewFields) {
|
||||
if (hasNewFields || hasNewCalendarSettings) {
|
||||
// Save the migrated settings to include new field mappings (non-blocking)
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -519,8 +519,8 @@ export class AdvancedCalendarView extends ItemView {
|
|||
views: {
|
||||
timeGridCustom: {
|
||||
type: 'timeGrid',
|
||||
duration: { days: calendarSettings.customDayCount },
|
||||
buttonText: `${calendarSettings.customDayCount} days`
|
||||
duration: { days: calendarSettings.customDayCount || 3 },
|
||||
buttonText: `${calendarSettings.customDayCount || 3} days`
|
||||
}
|
||||
},
|
||||
height: '100%',
|
||||
|
|
@ -1769,8 +1769,8 @@ export class AdvancedCalendarView extends ItemView {
|
|||
this.calendar.setOption('views', {
|
||||
timeGridCustom: {
|
||||
type: 'timeGrid',
|
||||
duration: { days: calendarSettings.customDayCount },
|
||||
buttonText: `${calendarSettings.customDayCount} days`
|
||||
duration: { days: calendarSettings.customDayCount || 3 },
|
||||
buttonText: `${calendarSettings.customDayCount || 3} days`
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue