mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-25 10:04:40 +00:00
chore: cleanup (#17284)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from "solid-js"
|
||||
import { Show, createEffect, createMemo, on, onCleanup, onMount } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { TextShimmer } from "./text-shimmer"
|
||||
|
||||
function common(active: string, done: string) {
|
||||
@@ -35,8 +36,12 @@ export function ToolStatusTitle(props: {
|
||||
const activeTail = createMemo(() => (suffix() ? split().active : props.activeText))
|
||||
const doneTail = createMemo(() => (suffix() ? split().done : props.doneText))
|
||||
|
||||
const [width, setWidth] = createSignal("auto")
|
||||
const [ready, setReady] = createSignal(false)
|
||||
const [state, setState] = createStore({
|
||||
width: "auto",
|
||||
ready: false,
|
||||
})
|
||||
const width = () => state.width
|
||||
const ready = () => state.ready
|
||||
let activeRef: HTMLSpanElement | undefined
|
||||
let doneRef: HTMLSpanElement | undefined
|
||||
let frame: number | undefined
|
||||
@@ -45,7 +50,7 @@ export function ToolStatusTitle(props: {
|
||||
const measure = () => {
|
||||
const target = props.active ? activeRef : doneRef
|
||||
const px = contentWidth(target)
|
||||
if (px > 0) setWidth(`${px}px`)
|
||||
if (px > 0) setState("width", `${px}px`)
|
||||
}
|
||||
|
||||
const schedule = () => {
|
||||
@@ -62,13 +67,13 @@ export function ToolStatusTitle(props: {
|
||||
|
||||
const finish = () => {
|
||||
if (typeof requestAnimationFrame !== "function") {
|
||||
setReady(true)
|
||||
setState("ready", true)
|
||||
return
|
||||
}
|
||||
if (readyFrame !== undefined) cancelAnimationFrame(readyFrame)
|
||||
readyFrame = requestAnimationFrame(() => {
|
||||
readyFrame = undefined
|
||||
setReady(true)
|
||||
setState("ready", true)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user