diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index eb47c6a37..9386609f9 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -8,6 +8,7 @@ "deselectAll": "deselect all", "editPlaylist": "edit $t(entity.playlist_one)", "goToPage": "go to page", + "largeFetch": "this action will attempt to fetch {{count}} items from your server", "moveToNext": "move to next", "moveToBottom": "move to bottom", "moveToTop": "move to top", @@ -64,6 +65,7 @@ "disable": "disable", "disc": "disc", "dismiss": "dismiss", + "doNotShowAgain": "do not show this again", "duration": "duration", "edit": "edit", "enable": "enable", @@ -259,6 +261,10 @@ "success": "server added successfully", "title": "add server" }, + "largeFetchConfirmation": { + "title": "add items to the queue", + "description": "This request will attempt to fetch {{count}} items from the server" + }, "addToPlaylist": { "create": "create $t(entity.playlist_one) {{playlist}}", "input_playlists": "$t(entity.playlist_other)", diff --git a/src/renderer/features/player/context/player-context.tsx b/src/renderer/features/player/context/player-context.tsx index bed2e2883..37cf2c7e0 100644 --- a/src/renderer/features/player/context/player-context.tsx +++ b/src/renderer/features/player/context/player-context.tsx @@ -13,9 +13,12 @@ import { useDeleteFavorite } from '/@/renderer/features/shared/mutations/delete- import { useSetRating } from '/@/renderer/features/shared/mutations/set-rating-mutation'; import { songsQueries } from '/@/renderer/features/songs/api/songs-api'; import { AddToQueueType, usePlayerActions } from '/@/renderer/store'; +import { Checkbox } from '/@/shared/components/checkbox/checkbox'; import { ConfirmModal } from '/@/shared/components/modal/modal'; +import { Stack } from '/@/shared/components/stack/stack'; import { Text } from '/@/shared/components/text/text'; import { toast } from '/@/shared/components/toast/toast'; +import { useLocalStorage } from '/@/shared/hooks/use-local-storage'; import { instanceOfCancellationError, LibraryItem, @@ -141,8 +144,17 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => { const timeoutIds = useRef>>({}); const queueFetchConfirmThreshold = 100; + const [doNotShowAgain, setDoNotShowAgain] = useLocalStorage({ + defaultValue: false, + key: 'large_fetch_confirmation', + }); + const confirmLargeFetch = useCallback( (itemCount: number): Promise => { + if (doNotShowAgain) { + return Promise.resolve(true); + } + return new Promise((resolve) => { openModal({ children: ( @@ -160,23 +172,31 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => { closeAllModals(); }} > - - {t('player.confirmLargeFetch', { - count: itemCount, - defaultValue: `You are about to add ${itemCount} items to the queue. Continue?`, - postProcess: 'sentenceCase', - })} - + + + {t('action.largeFetch', { + count: itemCount, + postProcess: 'sentenceCase', + })} + + { + setDoNotShowAgain(event.currentTarget.checked); + }} + /> + ), - title: t('player.confirmLargeFetchTitle', { - defaultValue: 'Confirm Large Queue Addition', - postProcess: 'titleCase', + title: t('common.areYouSure', { + postProcess: 'sentenceCase', }), }); }); }, - [t], + [doNotShowAgain, setDoNotShowAgain, t], ); const addToQueueByData = useCallback(