refactor: code clean up

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-06 22:42:31 -04:00
parent df531908f3
commit 3c0ea698b1
8 changed files with 62 additions and 66 deletions
+19 -20
View File
@@ -62,18 +62,17 @@ const {
editingCollection,
collectionEditorMode,
collectionEditorType,
isTaskView,
isTasksSection,
} = storeToRefs(chronoUiStore);
const { loadVisibleRange: loadVisibleRangeOperations } = chronoOperationsStore;
const {
initialize,
setViewMode,
setCurrentDate,
selectCalendar,
selectSection,
selectDate,
selectCollection,
openEditCalendar,
selectTaskList,
openEditTaskList,
createEventFromDate,
startEditingSelectedEntity,
@@ -120,10 +119,10 @@ async function onFilesSelected(event: Event) {
if (files.length) await openImport(files)
}
function syncViewModeFromRoute() {
function selectSectionFromRoute() {
const routePath = route.path;
const mode = routePath.endsWith('/tasks') ? 'tasks' : 'calendar';
setViewMode(mode);
const section = routePath.endsWith('/tasks') ? 'tasks' : 'calendar';
selectSection(section);
}
function handleCalendarViewChange(view: CalendarViewType) {
@@ -150,16 +149,16 @@ watch(
onMounted(async () => {
try {
syncViewModeFromRoute();
await initialize(isTaskView.value ? 'tasks' : 'calendar');
selectSectionFromRoute();
await initialize(isTasksSection.value ? 'tasks' : 'calendar');
} catch (error) {
console.error('[Chrono] - Failed to load data from ChronoManager:', error);
}
});
watch(() => route.fullPath, async () => {
syncViewModeFromRoute();
if (isTaskView.value) {
selectSectionFromRoute();
if (isTasksSection.value) {
await ensureTasksLoaded();
}
});
@@ -187,7 +186,7 @@ watch(() => route.fullPath, async () => {
<!-- View Switcher for Calendar -->
<v-btn-toggle
v-if="!isTaskView"
v-if="!isTasksSection"
:model-value="calendarView"
color="primary"
variant="outlined"
@@ -214,11 +213,11 @@ watch(() => route.fullPath, async () => {
>
<div class="pa-4">
<CollectionList
v-if="!isTaskView"
v-if="!isTasksSection"
:collections="collections"
:selected-collection="selectedCollection"
type="calendar"
@select="selectCalendar"
@select="selectCollection"
@edit="openEditCalendar"
@toggle-visibility="toggleCalendarVisibility"
/>
@@ -227,12 +226,12 @@ watch(() => route.fullPath, async () => {
:collections="collections"
:selected-collection="selectedCollection"
type="tasklist"
@select="selectTaskList"
@select="selectCollection"
@edit="openEditTaskList"
/>
<v-btn
v-if="!isTaskView"
v-if="!isTasksSection"
variant="tonal"
color="primary"
block
@@ -262,7 +261,7 @@ watch(() => route.fullPath, async () => {
<input ref="fileInputRef" type="file" accept=".ics,text/calendar" multiple class="d-none" @change="onFilesSelected" />
<!-- Mini Calendar Widget -->
<v-card v-if="!isTaskView" class="mt-4" variant="outlined">
<v-card v-if="!isTasksSection" class="mt-4" variant="outlined">
<v-card-text class="pa-2">
<MiniCalendar v-model="currentDate" />
</v-card-text>
@@ -299,7 +298,7 @@ watch(() => route.fullPath, async () => {
<v-progress-linear v-if="loading" indeterminate color="primary" />
<CalendarView
v-if="!isTaskView"
v-if="!isTasksSection"
:view="calendarView"
:current-date="currentDate"
:calendars="calendars"
@@ -307,7 +306,7 @@ watch(() => route.fullPath, async () => {
:initial-agenda-view-span="agendaViewSpan"
@event-click="editEvent"
@date-click="createEventFromDate"
@update:current-date="setCurrentDate"
@update:current-date="selectDate"
@update:days-span="setDaysViewSpan"
@update:agenda-span="setAgendaViewSpan"
/>