[WebUI] Model Manager Lag Fix (#2720)

Model Manager lags a bit if you have a lot of models.

Basically added a fake delay to rendering the model list so the modal
has time to load first. Hacky but if it works it works.
This commit is contained in:
psychedelicious 2023-02-19 14:42:25 +11:00 committed by GitHub
commit e19b08b149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 45 deletions

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>InvokeAI - A Stable Diffusion Toolkit</title> <title>InvokeAI - A Stable Diffusion Toolkit</title>
<link rel="shortcut icon" type="icon" href="./assets/favicon-0d253ced.ico" /> <link rel="shortcut icon" type="icon" href="./assets/favicon-0d253ced.ico" />
<script type="module" crossorigin src="./assets/index-c55cecd9.js"></script> <script type="module" crossorigin src="./assets/index-fff3415a.js"></script>
<link rel="stylesheet" href="./assets/index-14cb2922.css"> <link rel="stylesheet" href="./assets/index-14cb2922.css">
</head> </head>

View File

@ -1,20 +1,21 @@
import { Box, Flex, Text } from '@chakra-ui/react'; import { Box, Flex, Spinner, Text } from '@chakra-ui/react';
import { createSelector } from '@reduxjs/toolkit';
import IAIInput from 'common/components/IAIInput'; import IAIInput from 'common/components/IAIInput';
import { useMemo, useState, useTransition } from 'react'; import IAIButton from 'common/components/IAIButton';
import AddModel from './AddModel'; import AddModel from './AddModel';
import ModelListItem from './ModelListItem'; import ModelListItem from './ModelListItem';
import MergeModels from './MergeModels';
import { useAppSelector } from 'app/storeHooks'; import { useAppSelector } from 'app/storeHooks';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import IAIButton from 'common/components/IAIButton'; import { createSelector } from '@reduxjs/toolkit';
import { systemSelector } from 'features/system/store/systemSelectors'; import { systemSelector } from 'features/system/store/systemSelectors';
import type { SystemState } from 'features/system/store/systemSlice'; import type { SystemState } from 'features/system/store/systemSlice';
import { isEqual, map } from 'lodash'; import { isEqual, map } from 'lodash';
import React, { useMemo, useState, useTransition } from 'react';
import type { ChangeEvent, ReactNode } from 'react'; import type { ChangeEvent, ReactNode } from 'react';
import MergeModels from './MergeModels';
const modelListSelector = createSelector( const modelListSelector = createSelector(
systemSelector, systemSelector,
@ -58,6 +59,16 @@ function ModelFilterButton({
const ModelList = () => { const ModelList = () => {
const models = useAppSelector(modelListSelector); const models = useAppSelector(modelListSelector);
const [renderModelList, setRenderModelList] = React.useState<boolean>(false);
React.useEffect(() => {
const timer = setTimeout(() => {
setRenderModelList(true);
}, 200);
return () => clearTimeout(timer);
}, []);
const [searchText, setSearchText] = useState<string>(''); const [searchText, setSearchText] = useState<string>('');
const [isSelectedFilter, setIsSelectedFilter] = useState< const [isSelectedFilter, setIsSelectedFilter] = useState<
'all' | 'ckpt' | 'diffusers' 'all' | 'ckpt' | 'diffusers'
@ -217,7 +228,19 @@ const ModelList = () => {
isActive={isSelectedFilter === 'diffusers'} isActive={isSelectedFilter === 'diffusers'}
/> />
</Flex> </Flex>
{renderModelListItems}
{renderModelList ? (
renderModelListItems
) : (
<Flex
width="100%"
minHeight="30rem"
justifyContent="center"
alignItems="center"
>
<Spinner />
</Flex>
)}
</Flex> </Flex>
</Flex> </Flex>
); );

File diff suppressed because one or more lines are too long