fix(ui): remove unused setting, fix missing translation for alerts

This commit is contained in:
psychedelicious
2024-09-12 23:28:11 +10:00
parent d2ab668fa0
commit 637960d67e
9 changed files with 21 additions and 61 deletions

View File

@@ -2035,6 +2035,7 @@
"events": "Events",
"queue": "Queue",
"metadata": "Metadata"
}
},
"showSendingToAlerts": "Alert When Sending to Different View"
}
}

View File

@@ -17,7 +17,7 @@ import {
} from 'features/controlLayers/components/CanvasRightPanel';
import { useImageViewer } from 'features/gallery/components/ImageViewer/useImageViewer';
import { useCurrentDestination } from 'features/queue/hooks/useCurrentDestination';
import { selectShowSendToAlerts, showSendToAlertsChanged } from 'features/system/store/systemSlice';
import { selectShowSendingToAlerts, showSendingToAlertsChanged } from 'features/system/store/systemSlice';
import { setActiveTab } from 'features/ui/store/uiSlice';
import { AnimatePresence, motion } from 'framer-motion';
import type { PropsWithChildren, ReactNode } from 'react';
@@ -116,10 +116,10 @@ const AlertWrapper = ({
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const showSendToAlerts = useAppSelector(selectShowSendToAlerts);
const showSendToAlerts = useAppSelector(selectShowSendingToAlerts);
const isHovered = useBoolean(false);
const onClickDontShowMeThese = useCallback(() => {
dispatch(showSendToAlertsChanged(false));
dispatch(showSendingToAlertsChanged(false));
isHovered.setFalse();
}, [dispatch, isHovered]);

View File

@@ -1,10 +1,7 @@
import { buildUseBoolean } from 'common/hooks/useBoolean';
import { useMemo } from 'react';
const hook = buildUseBoolean(true);
const useImageViewerState = hook[0];
export const $imageViewerState = hook[1];
const [useImageViewerState, $imageViewerState] = buildUseBoolean(true);
export const useImageViewer = () => {
const imageViewerState = useImageViewerState();

View File

@@ -1,5 +1,4 @@
import { useGetCurrentQueueItemQuery } from "services/api/endpoints/queue";
import { useGetCurrentQueueItemQuery } from 'services/api/endpoints/queue';
export const useCurrentDestination = () => {
const { destination } = useGetCurrentQueueItemQuery(undefined, {

View File

@@ -24,8 +24,7 @@ import { useRefreshAfterResetModal } from 'features/system/components/SettingsMo
import { SettingsDeveloperLogIsEnabled } from 'features/system/components/SettingsModal/SettingsDeveloperLogIsEnabled';
import { SettingsDeveloperLogLevel } from 'features/system/components/SettingsModal/SettingsDeveloperLogLevel';
import { SettingsDeveloperLogNamespaces } from 'features/system/components/SettingsModal/SettingsDeveloperLogNamespaces';
import { SettingsShowSendToToasts } from 'features/system/components/SettingsModal/SettingsShowSendToAlerts';
import { SettingsShowSendToAlerts } from 'features/system/components/SettingsModal/SettingsShowSendToToasts';
import { SettingsShowSendingToDifferentViewAlerts } from 'features/system/components/SettingsModal/SettingsShowSendingToDifferentViewAlerts';
import { useClearIntermediates } from 'features/system/components/SettingsModal/useClearIntermediates';
import { StickyScrollable } from 'features/system/components/StickyScrollable';
import {
@@ -177,8 +176,7 @@ const SettingsModal = ({ config = defaultConfig }: SettingsModalProps) => {
<FormLabel>{t('settings.confirmOnDelete')}</FormLabel>
<Switch isChecked={shouldConfirmOnDelete} onChange={handleChangeShouldConfirmOnDelete} />
</FormControl>
<SettingsShowSendToAlerts />
<SettingsShowSendToToasts />
<SettingsShowSendingToDifferentViewAlerts />
</StickyScrollable>
<StickyScrollable title={t('settings.generation')}>

View File

@@ -1,28 +0,0 @@
import { FormControl, FormLabel, Switch } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { selectShowSendToAlerts, showSendToAlertsChanged } from 'features/system/store/systemSlice';
import type { ChangeEvent } from 'react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
export const SettingsShowSendToAlerts = memo(() => {
const dispatch = useAppDispatch();
const { t } = useTranslation();
const showSendToAlerts = useAppSelector(selectShowSendToAlerts);
const onChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
dispatch(showSendToAlertsChanged(e.target.checked));
},
[dispatch]
);
return (
<FormControl>
<FormLabel>{t('settings.showAlertsIfLost')}</FormLabel>
<Switch isChecked={showSendToAlerts} onChange={onChange} />
</FormControl>
);
});
SettingsShowSendToAlerts.displayName = 'SettingsShowSendToAlerts';

View File

@@ -1,28 +1,28 @@
import { FormControl, FormLabel, Switch } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { selectShowSendToToasts, showSendToToastsChanged } from 'features/system/store/systemSlice';
import { selectShowSendingToAlerts, showSendingToAlertsChanged } from 'features/system/store/systemSlice';
import type { ChangeEvent } from 'react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
export const SettingsShowSendToToasts = memo(() => {
export const SettingsShowSendingToDifferentViewAlerts = memo(() => {
const dispatch = useAppDispatch();
const { t } = useTranslation();
const isChecked = useAppSelector(selectShowSendToToasts);
const isChecked = useAppSelector(selectShowSendingToAlerts);
const onChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
dispatch(showSendToToastsChanged(e.target.checked));
dispatch(showSendingToAlertsChanged(e.target.checked));
},
[dispatch]
);
return (
<FormControl>
<FormLabel>{t('settings.showAlertsIfLost')}</FormLabel>
<FormLabel>{t('system.showSendingToAlerts')}</FormLabel>
<Switch isChecked={isChecked} onChange={onChange} />
</FormControl>
);
});
SettingsShowSendToToasts.displayName = 'SettingsShowSendToToasts';
SettingsShowSendingToDifferentViewAlerts.displayName = 'SettingsShowSendingToDifferentViewAlerts';

View File

@@ -19,8 +19,7 @@ const initialSystemState: SystemState = {
logIsEnabled: true,
logLevel: 'debug',
logNamespaces: [...zLogNamespace.options],
showSendToAlerts: true,
showSendToToasts: true,
showSendingToDifferentViewAlerts: true,
};
export const systemSlice = createSlice({
@@ -58,11 +57,8 @@ export const systemSlice = createSlice({
setShouldEnableInformationalPopovers(state, action: PayloadAction<boolean>) {
state.shouldEnableInformationalPopovers = action.payload;
},
showSendToAlertsChanged: (state, action: PayloadAction<boolean>) => {
state.showSendToAlerts = action.payload;
},
showSendToToastsChanged: (state, action: PayloadAction<boolean>) => {
state.showSendToToasts = action.payload;
showSendingToAlertsChanged: (state, action: PayloadAction<boolean>) => {
state.showSendingToDifferentViewAlerts = action.payload;
},
},
});
@@ -77,8 +73,7 @@ export const {
shouldUseNSFWCheckerChanged,
shouldUseWatermarkerChanged,
setShouldEnableInformationalPopovers,
showSendToAlertsChanged,
showSendToToastsChanged,
showSendingToAlertsChanged,
} = systemSlice.actions;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -113,5 +108,4 @@ export const selectSystemShouldAntialiasProgressImage = createSystemSelector(
export const selectSystemShouldEnableInformationalPopovers = createSystemSelector(
(system) => system.shouldEnableInformationalPopovers
);
export const selectShowSendToAlerts = createSystemSelector((s) => s.showSendToAlerts);
export const selectShowSendToToasts = createSystemSelector((s) => s.showSendToToasts);
export const selectShowSendingToAlerts = createSystemSelector((s) => s.showSendingToDifferentViewAlerts);

View File

@@ -39,6 +39,5 @@ export interface SystemState {
logIsEnabled: boolean;
logLevel: LogLevel;
logNamespaces: LogNamespace[];
showSendToAlerts: boolean;
showSendToToasts: boolean;
showSendingToDifferentViewAlerts: boolean;
}