feat: add habits to today overview
This commit is contained in:
@@ -9,7 +9,11 @@ type View = 'habits' | 'today-habits' | 'settings'
|
||||
type Habit = { id: string; name: string; kind?: string; target?: number; max_value?: number | null; unit?: string; cells?: Array<{ day: string; scheduled?:boolean; paused?:boolean; value: number | boolean }>; stats?: Record<string, number> }
|
||||
type Session = { id: string; created_at?: string; last_seen_at?: string; current?: boolean; user_agent?: string }
|
||||
const props = defineProps<{ view: View }>()
|
||||
const emit = defineEmits<{ changed: []; notice: [message: string] }>()
|
||||
const emit = defineEmits<{
|
||||
changed: []
|
||||
notice: [message: string]
|
||||
summary: [value: { total: number; completed: number }]
|
||||
}>()
|
||||
const habits = ref<Habit[]>([])
|
||||
const sessions = ref<Session[]>([])
|
||||
const audit = ref<any[]>([])
|
||||
@@ -39,6 +43,11 @@ const hideCompletedHabits = ref(readStoredBoolean(window.localStorage, HIDE_COMP
|
||||
const todayHabits = computed(() => habits.value.filter((item) => isHabitScheduledToday(item, todayKey.value)))
|
||||
const visibleTodayHabits = computed(() => hideCompletedHabits.value ? todayHabits.value.filter((item) => !isDone(item, todayKey.value)) : todayHabits.value)
|
||||
const visibleHabits = computed(() => hideCompletedHabits.value ? habits.value.filter((item) => !isDone(item, todayKey.value)) : habits.value)
|
||||
const todayHabitSummary = computed(() => ({
|
||||
total: todayHabits.value.length,
|
||||
completed: todayHabits.value.filter((item) => isDone(item, todayKey.value)).length,
|
||||
}))
|
||||
watch(todayHabitSummary, (value) => emit('summary', value), { immediate: true })
|
||||
watch(hideCompletedHabits, (value) => writeStoredBoolean(window.localStorage, HIDE_COMPLETED_HABITS_STORAGE_KEY, value))
|
||||
let dayRolloverTimer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
|
||||
Reference in New Issue
Block a user