mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add option to hide fetch confirmation
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"deselectAll": "deselect all",
|
"deselectAll": "deselect all",
|
||||||
"editPlaylist": "edit $t(entity.playlist_one)",
|
"editPlaylist": "edit $t(entity.playlist_one)",
|
||||||
"goToPage": "go to page",
|
"goToPage": "go to page",
|
||||||
|
"largeFetch": "this action will attempt to fetch {{count}} items from your server",
|
||||||
"moveToNext": "move to next",
|
"moveToNext": "move to next",
|
||||||
"moveToBottom": "move to bottom",
|
"moveToBottom": "move to bottom",
|
||||||
"moveToTop": "move to top",
|
"moveToTop": "move to top",
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
"disable": "disable",
|
"disable": "disable",
|
||||||
"disc": "disc",
|
"disc": "disc",
|
||||||
"dismiss": "dismiss",
|
"dismiss": "dismiss",
|
||||||
|
"doNotShowAgain": "do not show this again",
|
||||||
"duration": "duration",
|
"duration": "duration",
|
||||||
"edit": "edit",
|
"edit": "edit",
|
||||||
"enable": "enable",
|
"enable": "enable",
|
||||||
@@ -259,6 +261,10 @@
|
|||||||
"success": "server added successfully",
|
"success": "server added successfully",
|
||||||
"title": "add server"
|
"title": "add server"
|
||||||
},
|
},
|
||||||
|
"largeFetchConfirmation": {
|
||||||
|
"title": "add items to the queue",
|
||||||
|
"description": "This request will attempt to fetch {{count}} items from the server"
|
||||||
|
},
|
||||||
"addToPlaylist": {
|
"addToPlaylist": {
|
||||||
"create": "create $t(entity.playlist_one) {{playlist}}",
|
"create": "create $t(entity.playlist_one) {{playlist}}",
|
||||||
"input_playlists": "$t(entity.playlist_other)",
|
"input_playlists": "$t(entity.playlist_other)",
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ import { useDeleteFavorite } from '/@/renderer/features/shared/mutations/delete-
|
|||||||
import { useSetRating } from '/@/renderer/features/shared/mutations/set-rating-mutation';
|
import { useSetRating } from '/@/renderer/features/shared/mutations/set-rating-mutation';
|
||||||
import { songsQueries } from '/@/renderer/features/songs/api/songs-api';
|
import { songsQueries } from '/@/renderer/features/songs/api/songs-api';
|
||||||
import { AddToQueueType, usePlayerActions } from '/@/renderer/store';
|
import { AddToQueueType, usePlayerActions } from '/@/renderer/store';
|
||||||
|
import { Checkbox } from '/@/shared/components/checkbox/checkbox';
|
||||||
import { ConfirmModal } from '/@/shared/components/modal/modal';
|
import { ConfirmModal } from '/@/shared/components/modal/modal';
|
||||||
|
import { Stack } from '/@/shared/components/stack/stack';
|
||||||
import { Text } from '/@/shared/components/text/text';
|
import { Text } from '/@/shared/components/text/text';
|
||||||
import { toast } from '/@/shared/components/toast/toast';
|
import { toast } from '/@/shared/components/toast/toast';
|
||||||
|
import { useLocalStorage } from '/@/shared/hooks/use-local-storage';
|
||||||
import {
|
import {
|
||||||
instanceOfCancellationError,
|
instanceOfCancellationError,
|
||||||
LibraryItem,
|
LibraryItem,
|
||||||
@@ -141,8 +144,17 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
const timeoutIds = useRef<null | Record<string, ReturnType<typeof setTimeout>>>({});
|
const timeoutIds = useRef<null | Record<string, ReturnType<typeof setTimeout>>>({});
|
||||||
const queueFetchConfirmThreshold = 100;
|
const queueFetchConfirmThreshold = 100;
|
||||||
|
|
||||||
|
const [doNotShowAgain, setDoNotShowAgain] = useLocalStorage({
|
||||||
|
defaultValue: false,
|
||||||
|
key: 'large_fetch_confirmation',
|
||||||
|
});
|
||||||
|
|
||||||
const confirmLargeFetch = useCallback(
|
const confirmLargeFetch = useCallback(
|
||||||
(itemCount: number): Promise<boolean> => {
|
(itemCount: number): Promise<boolean> => {
|
||||||
|
if (doNotShowAgain) {
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
openModal({
|
openModal({
|
||||||
children: (
|
children: (
|
||||||
@@ -160,23 +172,31 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
closeAllModals();
|
closeAllModals();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Stack>
|
||||||
<Text>
|
<Text>
|
||||||
{t('player.confirmLargeFetch', {
|
{t('action.largeFetch', {
|
||||||
count: itemCount,
|
count: itemCount,
|
||||||
defaultValue: `You are about to add ${itemCount} items to the queue. Continue?`,
|
|
||||||
postProcess: 'sentenceCase',
|
postProcess: 'sentenceCase',
|
||||||
})}
|
})}
|
||||||
</Text>
|
</Text>
|
||||||
|
<Checkbox
|
||||||
|
label={t('common.doNotShowAgain', {
|
||||||
|
postProcess: 'sentenceCase',
|
||||||
|
})}
|
||||||
|
onChange={(event) => {
|
||||||
|
setDoNotShowAgain(event.currentTarget.checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
</ConfirmModal>
|
</ConfirmModal>
|
||||||
),
|
),
|
||||||
title: t('player.confirmLargeFetchTitle', {
|
title: t('common.areYouSure', {
|
||||||
defaultValue: 'Confirm Large Queue Addition',
|
postProcess: 'sentenceCase',
|
||||||
postProcess: 'titleCase',
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[t],
|
[doNotShowAgain, setDoNotShowAgain, t],
|
||||||
);
|
);
|
||||||
|
|
||||||
const addToQueueByData = useCallback(
|
const addToQueueByData = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user