-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mary Hipp
authored and
Mary Hipp
committed
Oct 11, 2024
1 parent
c694668
commit 09c116e
Showing
6 changed files
with
133 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 34 additions & 34 deletions
68
invokeai/frontend/web/src/features/modelManagerV2/hooks/useBuildModelsToInstall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import { EMPTY_ARRAY } from "app/store/constants"; | ||
import { useCallback,useMemo } from "react"; | ||
import { modelConfigsAdapterSelectors,useGetModelConfigsQuery } from "services/api/endpoints/models"; | ||
import type { StarterModel } from "services/api/types"; | ||
import { EMPTY_ARRAY } from 'app/store/constants'; | ||
import { useCallback, useMemo } from 'react'; | ||
import { modelConfigsAdapterSelectors, useGetModelConfigsQuery } from 'services/api/endpoints/models'; | ||
import type { StarterModel } from 'services/api/types'; | ||
|
||
export const useBuildModelsToInstall = () => { | ||
const { data: modelListRes } = useGetModelConfigsQuery(); | ||
const modelList = useMemo(() => { | ||
if (!modelListRes) { | ||
return EMPTY_ARRAY; | ||
} | ||
const { data: modelListRes } = useGetModelConfigsQuery(); | ||
const modelList = useMemo(() => { | ||
if (!modelListRes) { | ||
return EMPTY_ARRAY; | ||
} | ||
|
||
return modelConfigsAdapterSelectors.selectAll(modelListRes); | ||
}, [modelListRes]); | ||
return modelConfigsAdapterSelectors.selectAll(modelListRes); | ||
}, [modelListRes]); | ||
|
||
const buildModelToInstall = useCallback( | ||
(starterModel: StarterModel) => { | ||
if ( | ||
modelList.some( | ||
(mc) => starterModel.base === mc.base && starterModel.name === mc.name && starterModel.type === mc.type | ||
) | ||
) { | ||
return undefined; | ||
} | ||
const buildModelToInstall = useCallback( | ||
(starterModel: StarterModel) => { | ||
if ( | ||
modelList.some( | ||
(mc) => starterModel.base === mc.base && starterModel.name === mc.name && starterModel.type === mc.type | ||
) | ||
) { | ||
return undefined; | ||
} | ||
|
||
const source = starterModel.source; | ||
const config = { | ||
name: starterModel.name, | ||
description: starterModel.description, | ||
type: starterModel.type, | ||
base: starterModel.base, | ||
format: starterModel.format, | ||
}; | ||
return { config, source }; | ||
}, | ||
[modelList] | ||
); | ||
const source = starterModel.source; | ||
const config = { | ||
name: starterModel.name, | ||
description: starterModel.description, | ||
type: starterModel.type, | ||
base: starterModel.base, | ||
format: starterModel.format, | ||
}; | ||
return { config, source }; | ||
}, | ||
[modelList] | ||
); | ||
|
||
return buildModelToInstall | ||
} | ||
return buildModelToInstall; | ||
}; |
4 changes: 2 additions & 2 deletions
4
...d/web/src/features/modelManagerV2/subpanels/AddModelPanel/StarterModels/StarterBundle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters