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
+15 -19
View File
@@ -5,12 +5,13 @@ import { EntityObject } from '@ChronoManager/models/entity'
import { EventObject } from '@ChronoManager/models/event'
import { TaskObject } from '@ChronoManager/models/task'
import type { ServiceObject } from '@ChronoManager/models/service'
import type { ChronoSection } from '@/types'
import { useChronoOperationsStore } from '@/stores/chronoOperationsStore'
export const useChronoUiStore = defineStore('chronoUiStore', () => {
const operationsStore = useChronoOperationsStore()
const viewMode = ref<'calendar' | 'tasks'>('calendar')
const section = ref<ChronoSection>('calendar')
const currentDate = ref(new Date())
const sidebarVisible = ref(true)
const selectedCollection = shallowRef<CollectionObject | null>(null)
@@ -24,22 +25,18 @@ export const useChronoUiStore = defineStore('chronoUiStore', () => {
const collectionEditorMode = ref<'create' | 'edit'>('create')
const collectionEditorType = ref<'calendar' | 'tasklist'>('calendar')
const isTaskView = computed(() => viewMode.value === 'tasks')
const isTasksSection = computed(() => section.value === 'tasks')
function setViewMode(mode: 'calendar' | 'tasks') {
viewMode.value = mode
function selectSection(target: ChronoSection) {
section.value = target
}
function setCurrentDate(date: Date) {
function selectDate(date: Date) {
currentDate.value = new Date(date)
}
function selectCalendar(calendar: CollectionObject) {
selectedCollection.value = calendar
}
function selectTaskList(list: CollectionObject) {
selectedCollection.value = list
function selectCollection(collection: CollectionObject) {
selectedCollection.value = collection
}
function openCollectionEditor(type: 'calendar' | 'tasklist') {
@@ -193,8 +190,8 @@ export const useChronoUiStore = defineStore('chronoUiStore', () => {
await operationsStore.finishImport(refresh)
}
async function initialize(viewMode: 'calendar' | 'tasks' = 'calendar') {
await operationsStore.initialize(viewMode)
async function initialize(initialSection: ChronoSection = 'calendar') {
await operationsStore.initialize(initialSection)
if (selectedCollection.value && !operationsStore.collections.some(
collection => collection.identifier === selectedCollection.value?.identifier,
)) {
@@ -203,7 +200,7 @@ export const useChronoUiStore = defineStore('chronoUiStore', () => {
}
return {
viewMode,
section,
currentDate,
sidebarVisible,
selectedCollection,
@@ -216,11 +213,10 @@ export const useChronoUiStore = defineStore('chronoUiStore', () => {
editingCollection,
collectionEditorMode,
collectionEditorType,
isTaskView,
setViewMode,
setCurrentDate,
selectCalendar,
selectTaskList,
isTasksSection,
selectSection,
selectDate,
selectCollection,
openCreateCalendar,
openCreateTaskList,
openEditCalendar,