fix: reset completed numeric habits from check button
ci / docker (push) Successful in 7m21s

This commit is contained in:
2026-09-07 17:00:43 +08:00
parent a1cb780774
commit 6ca613f5fa
3 changed files with 15 additions and 5 deletions
+2 -4
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
import { Activity, ArchiveRestore, Check, Download, FileJson, LogOut, RefreshCw, Trash2, Upload, X } from 'lucide-vue-next'
import { dateKey, isHabitComplete, isHabitScheduledToday, mergePage, nextHabitSwipeValue, previousHabitSwipeValue, shouldToggleRowSwipe } from './lib/mvp-utils'
import { dateKey, habitButtonValue, isHabitComplete, isHabitScheduledToday, mergePage, nextHabitSwipeValue, previousHabitSwipeValue, shouldToggleRowSwipe } from './lib/mvp-utils'
import { csrfHeader } from './lib/csrf'
type View = 'habits' | 'today-habits' | 'settings'
@@ -187,9 +187,7 @@ function cancelHabitSwipe(h?: Habit) {
async function toggleHabitFromButton(h: Habit) {
const current = logFor(h, todayKey.value)?.value
const previous = current ?? 0
const next = isDone(h, todayKey.value)
? previousHabitSwipeValue(h.kind, current)
: nextHabitSwipeValue(h.kind, current, h.target ?? 1)
const next = habitButtonValue(h.kind, current, h.target ?? 1)
setLocalHabitValue(h, next)
try {
await request(`/habits/${h.id}/logs/${todayKey.value}`, { method: 'PUT', body: JSON.stringify({ value: next }) })