From e7e884d8aaf699d110dff16856bcfd5aa3f51fd6 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Aug 2026 21:56:35 +0000 Subject: [PATCH] fix(kock): ta bort buggig in-app-timer, ersatt med statisk tidshint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Timern (setInterval-nedrakning per steg) forsvann vid stegbyte och hade ingen bakgrund/notis. Borttagen helt – visar nu bara stegets ungefarliga tid som text ("⏱ 5 min – anvand din telefons egen timer"). Ingen nedrakning, ingen bugg. --- apps/mobile/src/app/cooking/[id].tsx | 47 +++++----------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/apps/mobile/src/app/cooking/[id].tsx b/apps/mobile/src/app/cooking/[id].tsx index 34ecfd2..4c60ba5 100644 --- a/apps/mobile/src/app/cooking/[id].tsx +++ b/apps/mobile/src/app/cooking/[id].tsx @@ -1,8 +1,7 @@ -import { useEffect, useRef, useState } from "react"; +import { useState } from "react"; import { Alert, Pressable, ScrollView, Text, View } from "react-native"; import { router, useLocalSearchParams } from "expo-router"; import { useKeepAwake } from "expo-keep-awake"; -import * as Haptics from "expo-haptics"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { api } from "@/lib/api"; import { t } from "@/lib/i18n"; @@ -54,8 +53,6 @@ export default function CookingScreen() { const queryClient = useQueryClient(); const [stepIndex, setStepIndex] = useState(0); const [showIngredients, setShowIngredients] = useState(false); - const [timerLeft, setTimerLeft] = useState(null); - const timerRef = useRef | null>(null); const [finishing, setFinishing] = useState(false); const [completedSessionId, setCompletedSessionId] = useState(null); const [mealBoxPortions, setMealBoxPortions] = useState(0); @@ -96,12 +93,6 @@ export default function CookingScreen() { Alert.alert(t("common.oops"), err instanceof Error ? err.message : t("common.error")), }); - useEffect(() => { - return () => { - if (timerRef.current) clearInterval(timerRef.current); - }; - }, []); - if (query.isLoading) return ; if (query.isError || !query.data) return void query.refetch()} />; const recipe = query.data; @@ -109,21 +100,6 @@ export default function CookingScreen() { const step = recipe.steps[stepIndex]; const isLast = stepIndex >= recipe.steps.length - 1; - const startTimer = (seconds: number) => { - if (timerRef.current) clearInterval(timerRef.current); - setTimerLeft(seconds); - timerRef.current = setInterval(() => { - setTimerLeft((prev) => { - if (prev == null || prev <= 1) { - if (timerRef.current) clearInterval(timerRef.current); - void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); - return 0; - } - return prev - 1; - }); - }, 1000); - }; - const finish = () => { setFinishing(true); }; @@ -310,26 +286,19 @@ export default function CookingScreen() { )} {step?.timerSeconds != null && ( - startTimer(step.timerSeconds!)} + - - {timerLeft != null ? formatTime(timerLeft) : formatTime(step.timerSeconds)} + + ⏱ {formatTime(step.timerSeconds)} - - {timerLeft != null - ? timerLeft === 0 - ? `${t("cooking.timerDone")} 🎉` - : t("cooking.timerRunning", { time: formatTime(timerLeft) }) - : t("cooking.timer")} - - + Ungefärlig tid för steget – använd din telefons egen timer. + )} {t("cooking.keepAwake")}