Skip to content

Commit

Permalink
clean up useIsAllowedToUpscale since its no longer necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
chainchompa authored and psychedelicious committed Jul 23, 2024
1 parent cb0bffe commit 4017609
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { logger } from 'app/logging/logger';
import type { AppStartListening } from 'app/store/middleware/listenerMiddleware';
import { parseify } from 'common/util/serialize';
import { buildAdHocUpscaleGraph } from 'features/nodes/util/graph/buildAdHocUpscaleGraph';
import { createIsAllowedToUpscaleSelector } from 'features/parameters/hooks/useIsAllowedToUpscale';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';
import { queueApi } from 'services/api/endpoints/queue';
Expand All @@ -20,22 +19,6 @@ export const addUpscaleRequestedListener = (startAppListening: AppStartListening
const { imageDTO } = action.payload;
const state = getState();

const { isAllowedToUpscale, detailTKey } = createIsAllowedToUpscaleSelector(imageDTO)(state);

// if we can't upscale, show a toast and return
if (!isAllowedToUpscale) {
log.error(
{ imageDTO },
t(detailTKey ?? 'parameters.isAllowedToUpscale.tooLarge') // should never coalesce
);
toast({
id: 'NOT_ALLOWED_TO_UPSCALE',
title: t(detailTKey ?? 'parameters.isAllowedToUpscale.tooLarge'), // should never coalesce
status: 'error',
});
return;
}

const enqueueBatchArg: BatchConfig = {
prepend: true,
batch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
useDisclosure,
} from '@invoke-ai/ui-library';
import { upscaleRequested } from 'app/store/middleware/listenerMiddleware/listeners/upscaleRequested';
import { useAppDispatch } from 'app/store/storeHooks';
import { useIsAllowedToUpscale } from 'features/parameters/hooks/useIsAllowedToUpscale';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { useIsQueueMutationInProgress } from 'features/queue/hooks/useIsQueueMutationInProgress';
import { UpscaleWarning } from 'features/settingsAccordions/components/UpscaleSettingsAccordion/UpscaleWarning';
import { memo, useCallback } from 'react';
Expand All @@ -25,18 +24,18 @@ type Props = { imageDTO?: ImageDTO };
const ParamUpscalePopover = (props: Props) => {
const { imageDTO } = props;
const dispatch = useAppDispatch();
const { simpleUpscaleModel } = useAppSelector((s) => s.upscale);
const inProgress = useIsQueueMutationInProgress();
const { t } = useTranslation();
const { isOpen, onOpen, onClose } = useDisclosure();
const { isAllowedToUpscale, detail } = useIsAllowedToUpscale(imageDTO);

const handleClickUpscale = useCallback(() => {
onClose();
if (!imageDTO || !isAllowedToUpscale) {
if (!imageDTO) {
return;
}
dispatch(upscaleRequested({ imageDTO }));
}, [dispatch, imageDTO, isAllowedToUpscale, onClose]);
}, [dispatch, imageDTO, onClose]);

return (
<Popover isOpen={isOpen} onClose={onClose} isLazy>
Expand All @@ -54,9 +53,8 @@ const ParamUpscalePopover = (props: Props) => {
<ParamSpandrelModel isMultidiffusion={false} />
<UpscaleWarning usesTile={false} />
<Button
tooltip={detail}
size="sm"
isDisabled={!imageDTO || inProgress || !isAllowedToUpscale}
isDisabled={!imageDTO || inProgress || !simpleUpscaleModel}
onClick={handleClickUpscale}
>
{t('parameters.upscaleImage')}
Expand Down

This file was deleted.

0 comments on commit 4017609

Please sign in to comment.