jbilcke-hf HF staff commited on
Commit
1805613
1 Parent(s): 0ce53fb

fix for the counter

Browse files
src/app/main.tsx CHANGED
@@ -13,7 +13,7 @@ import { TextareaField } from "@/components/form/textarea-field"
13
  import { cn, generateRandomStory } from "@/lib/utils"
14
  import { defaultPrompt } from "./config"
15
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
16
- import { useOrientation, useProgressTimer, useQueryStringParams, useStoryPromptDraft } from "@/lib/hooks"
17
  import { BottomBar, VideoPreview } from "@/components/interface"
18
  import { MainTitle } from "@/components/interface/main-title"
19
  import { LoadClapButton } from "@/components/interface/load-clap-button"
@@ -23,7 +23,7 @@ import { Characters } from "@/components/interface/characters"
23
 
24
  export function Main() {
25
  const { storyPromptDraft, setStoryPromptDraft, promptDraftRef } = useStoryPromptDraft()
26
- const { isBusy } = useProgressTimer()
27
  const { orientation, toggleOrientation } = useOrientation()
28
  const { handleSubmit } = useProcessors()
29
  useQueryStringParams()
 
13
  import { cn, generateRandomStory } from "@/lib/utils"
14
  import { defaultPrompt } from "./config"
15
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
16
+ import { useIsBusy, useOrientation, useProgressTimer, useQueryStringParams, useStoryPromptDraft } from "@/lib/hooks"
17
  import { BottomBar, VideoPreview } from "@/components/interface"
18
  import { MainTitle } from "@/components/interface/main-title"
19
  import { LoadClapButton } from "@/components/interface/load-clap-button"
 
23
 
24
  export function Main() {
25
  const { storyPromptDraft, setStoryPromptDraft, promptDraftRef } = useStoryPromptDraft()
26
+ const { isBusy } = useIsBusy()
27
  const { orientation, toggleOrientation } = useOrientation()
28
  const { handleSubmit } = useProcessors()
29
  useQueryStringParams()
src/lib/hooks/useProgressTimer.ts CHANGED
@@ -11,7 +11,9 @@ export function useProgressTimer() {
11
  const { isBusy, busyRef } = useIsBusy()
12
 
13
  const timerFn = async () => {
14
- const { isBusy, progress, stage } = useStore.getState()
 
 
15
 
16
  clearTimeout(timerRef.current)
17
  if (!isBusy || stage === "idle") {
@@ -34,10 +36,19 @@ export function useProgressTimer() {
34
  timerRef.current = setTimeout(timerFn, 1600)
35
  }
36
 
 
 
37
  useEffect(() => {
38
  timerFn()
39
  clearTimeout(timerRef.current)
40
- if (!isBusy) { return }
 
 
 
 
 
 
 
41
  timerRef.current = setTimeout(timerFn, 0)
42
  }, [isBusy])
43
 
 
11
  const { isBusy, busyRef } = useIsBusy()
12
 
13
  const timerFn = async () => {
14
+ const { progress, stage } = useStore.getState()
15
+
16
+ let isBusy = busyRef.current
17
 
18
  clearTimeout(timerRef.current)
19
  if (!isBusy || stage === "idle") {
 
36
  timerRef.current = setTimeout(timerFn, 1600)
37
  }
38
 
39
+ // const running = useRef(false)
40
+
41
  useEffect(() => {
42
  timerFn()
43
  clearTimeout(timerRef.current)
44
+ let isBusy = busyRef.current
45
+ if (!isBusy) {
46
+ return
47
+ }/* else if (running.current) {
48
+ return
49
+ }
50
+ */
51
+ // running.current = true
52
  timerRef.current = setTimeout(timerFn, 0)
53
  }, [isBusy])
54