bugfixes
This commit is contained in:
parent
13fe32577f
commit
69ba7cbdbd
BIN
backend/dist/nsfwapp-linux-amd64
vendored
BIN
backend/dist/nsfwapp-linux-amd64
vendored
Binary file not shown.
BIN
backend/dist/nsfwapp.exe
vendored
BIN
backend/dist/nsfwapp.exe
vendored
Binary file not shown.
BIN
backend/dist/nsfwapp_amd64.deb
vendored
BIN
backend/dist/nsfwapp_amd64.deb
vendored
Binary file not shown.
@ -1849,6 +1849,19 @@ export default function App() {
|
|||||||
setModelsCount(headerStats.totalCount)
|
setModelsCount(headerStats.totalCount)
|
||||||
}, [headerStats.totalCount])
|
}, [headerStats.totalCount])
|
||||||
|
|
||||||
|
const handleModelsCountChange = useCallback((count: number) => {
|
||||||
|
const nextCount = Number.isFinite(count) && count > 0 ? Math.floor(count) : 0
|
||||||
|
|
||||||
|
setHeaderStats((prev) =>
|
||||||
|
prev.totalCount === nextCount
|
||||||
|
? prev
|
||||||
|
: {
|
||||||
|
...prev,
|
||||||
|
totalCount: nextCount,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const overviewInFlightRef = useRef(false)
|
const overviewInFlightRef = useRef(false)
|
||||||
const overviewLastSigRef = useRef('')
|
const overviewLastSigRef = useRef('')
|
||||||
const overviewLastAtRef = useRef(0)
|
const overviewLastAtRef = useRef(0)
|
||||||
@ -1876,8 +1889,6 @@ export default function App() {
|
|||||||
if (overviewLastSigRef.current === sig && now - overviewLastAtRef.current < MODELS_OVERVIEW_COOLDOWN_MS) return
|
if (overviewLastSigRef.current === sig && now - overviewLastAtRef.current < MODELS_OVERVIEW_COOLDOWN_MS) return
|
||||||
|
|
||||||
overviewInFlightRef.current = true
|
overviewInFlightRef.current = true
|
||||||
overviewLastSigRef.current = sig
|
|
||||||
overviewLastAtRef.current = now
|
|
||||||
overviewAbortRef.current?.abort()
|
overviewAbortRef.current?.abort()
|
||||||
|
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
@ -1915,6 +1926,9 @@ export default function App() {
|
|||||||
: next
|
: next
|
||||||
})
|
})
|
||||||
|
|
||||||
|
overviewLastSigRef.current = sig
|
||||||
|
overviewLastAtRef.current = now
|
||||||
|
|
||||||
const safeList = Array.isArray(data?.models) ? data.models : []
|
const safeList = Array.isArray(data?.models) ? data.models : []
|
||||||
const built = buildModelsByKey(safeList)
|
const built = buildModelsByKey(safeList)
|
||||||
|
|
||||||
@ -4462,7 +4476,10 @@ export default function App() {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{selectedTab === 'models' ? (
|
{selectedTab === 'models' ? (
|
||||||
<ModelsTab onAddToDownloads={handleAddToDownloads} />
|
<ModelsTab
|
||||||
|
onAddToDownloads={handleAddToDownloads}
|
||||||
|
onModelsCountChange={handleModelsCountChange}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{trainingTabMounted ? (
|
{trainingTabMounted ? (
|
||||||
|
|||||||
@ -292,10 +292,12 @@ function TableIcon() {
|
|||||||
|
|
||||||
type ModelsTabProps = {
|
type ModelsTabProps = {
|
||||||
onAddToDownloads?: (job: RecordJob) => void | Promise<boolean>
|
onAddToDownloads?: (job: RecordJob) => void | Promise<boolean>
|
||||||
|
onModelsCountChange?: (count: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ModelsTab({ onAddToDownloads }: ModelsTabProps) {
|
export default function ModelsTab({ onAddToDownloads, onModelsCountChange }: ModelsTabProps) {
|
||||||
const [models, setModels] = useState<StoredModel[]>([])
|
const [models, setModels] = useState<StoredModel[]>([])
|
||||||
|
const modelsLoadedRef = useRef(false)
|
||||||
const flagsInFlightRef = useRef<Record<string, true>>({})
|
const flagsInFlightRef = useRef<Record<string, true>>({})
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
@ -508,18 +510,25 @@ export default function ModelsTab({ onAddToDownloads }: ModelsTabProps) {
|
|||||||
: []
|
: []
|
||||||
|
|
||||||
setModels(list)
|
setModels(list)
|
||||||
|
modelsLoadedRef.current = true
|
||||||
|
onModelsCountChange?.(list.length)
|
||||||
void refreshVideoCounts()
|
void refreshVideoCounts()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setErr(e?.message ?? String(e))
|
setErr(e?.message ?? String(e))
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}, [refreshVideoCounts])
|
}, [onModelsCountChange, refreshVideoCounts])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void refresh()
|
void refresh()
|
||||||
}, [refresh])
|
}, [refresh])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!modelsLoadedRef.current) return
|
||||||
|
onModelsCountChange?.(models.length)
|
||||||
|
}, [models.length, onModelsCountChange])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onChanged = (ev: Event) => {
|
const onChanged = (ev: Event) => {
|
||||||
const e = ev as CustomEvent<any>
|
const e = ev as CustomEvent<any>
|
||||||
@ -553,6 +562,7 @@ export default function ModelsTab({ onAddToDownloads }: ModelsTabProps) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onDbChanged = () => {
|
const onDbChanged = () => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
|
modelsLoadedRef.current = false
|
||||||
setModels([])
|
setModels([])
|
||||||
void refresh()
|
void refresh()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user