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)
|
||||
}, [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 overviewLastSigRef = useRef('')
|
||||
const overviewLastAtRef = useRef(0)
|
||||
@ -1876,8 +1889,6 @@ export default function App() {
|
||||
if (overviewLastSigRef.current === sig && now - overviewLastAtRef.current < MODELS_OVERVIEW_COOLDOWN_MS) return
|
||||
|
||||
overviewInFlightRef.current = true
|
||||
overviewLastSigRef.current = sig
|
||||
overviewLastAtRef.current = now
|
||||
overviewAbortRef.current?.abort()
|
||||
|
||||
const controller = new AbortController()
|
||||
@ -1915,6 +1926,9 @@ export default function App() {
|
||||
: next
|
||||
})
|
||||
|
||||
overviewLastSigRef.current = sig
|
||||
overviewLastAtRef.current = now
|
||||
|
||||
const safeList = Array.isArray(data?.models) ? data.models : []
|
||||
const built = buildModelsByKey(safeList)
|
||||
|
||||
@ -4462,7 +4476,10 @@ export default function App() {
|
||||
) : null}
|
||||
|
||||
{selectedTab === 'models' ? (
|
||||
<ModelsTab onAddToDownloads={handleAddToDownloads} />
|
||||
<ModelsTab
|
||||
onAddToDownloads={handleAddToDownloads}
|
||||
onModelsCountChange={handleModelsCountChange}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{trainingTabMounted ? (
|
||||
|
||||
@ -292,10 +292,12 @@ function TableIcon() {
|
||||
|
||||
type ModelsTabProps = {
|
||||
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 modelsLoadedRef = useRef(false)
|
||||
const flagsInFlightRef = useRef<Record<string, true>>({})
|
||||
|
||||
const [loading, setLoading] = useState(false)
|
||||
@ -508,18 +510,25 @@ export default function ModelsTab({ onAddToDownloads }: ModelsTabProps) {
|
||||
: []
|
||||
|
||||
setModels(list)
|
||||
modelsLoadedRef.current = true
|
||||
onModelsCountChange?.(list.length)
|
||||
void refreshVideoCounts()
|
||||
} catch (e: any) {
|
||||
setErr(e?.message ?? String(e))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [refreshVideoCounts])
|
||||
}, [onModelsCountChange, refreshVideoCounts])
|
||||
|
||||
useEffect(() => {
|
||||
void refresh()
|
||||
}, [refresh])
|
||||
|
||||
useEffect(() => {
|
||||
if (!modelsLoadedRef.current) return
|
||||
onModelsCountChange?.(models.length)
|
||||
}, [models.length, onModelsCountChange])
|
||||
|
||||
useEffect(() => {
|
||||
const onChanged = (ev: Event) => {
|
||||
const e = ev as CustomEvent<any>
|
||||
@ -553,6 +562,7 @@ export default function ModelsTab({ onAddToDownloads }: ModelsTabProps) {
|
||||
useEffect(() => {
|
||||
const onDbChanged = () => {
|
||||
setPage(1)
|
||||
modelsLoadedRef.current = false
|
||||
setModels([])
|
||||
void refresh()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user