fix: land on today and swipe count habits incrementally
ci / docker (push) Successful in 3m16s

This commit is contained in:
2026-09-06 10:44:06 +08:00
parent cc98bc53e9
commit 4c93d0e1f8
7 changed files with 90 additions and 51 deletions
+17 -1
View File
@@ -24,11 +24,27 @@ export function isTaskView(view: string) {
return view === 'tasks' || view === 'today' || view === 'upcoming'
}
export function defaultView() {
return 'today' as const
}
export function isHabitComplete(kind: string | undefined, value: number | boolean | undefined, target = 1) {
if (kind === 'numeric') return Number(value ?? 0) >= target
return Boolean(value)
}
export function nextHabitSwipeValue(kind: string | undefined, current: number | boolean | undefined, target = 1) {
const value = Number(current ?? 0)
if (kind === 'numeric') return Math.min(value + 1, target)
return value > 0 ? 0 : 1
}
export function previousHabitSwipeValue(kind: string | undefined, current: number | boolean | undefined) {
const value = Number(current ?? 0)
if (kind === 'numeric') return Math.max(0, value - 1)
return 0
}
export function numericHabitInputValue(input: number | string | undefined) {
if (input === undefined || input === '') return null
const value = Number(input)
@@ -36,5 +52,5 @@ export function numericHabitInputValue(input: number | string | undefined) {
}
export function shouldToggleRowSwipe(deltaX: number, deltaY: number) {
return deltaX >= 64 && Math.abs(deltaY) <= 24 && deltaX > Math.abs(deltaY) * 1.5
return deltaX >= 64 && deltaX > Math.abs(deltaY) * 1.5
}