fix(playlist): migrate duplicate modal to Svelte 5 and add i18n
Migrate PlaylistDuplicateConfirmModal from Svelte 4 (export let, createEventDispatcher, on:click) to Svelte 5 ($props, callback props, onclick). Replace hardcoded English strings with i18n keys under playlist.duplicates for all 4 locales (en, es, de, fr).
This commit is contained in:
1 parent
ae1a3533a8
commit
f85d04fa68
6 files changed
+69
-43
No files matched your search
@@ -1,67 +1,65 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { t } from '$lib/i18n';
|
||||||
import Modal from './Modal.svelte';
|
import Modal from './Modal.svelte';
|
||||||
import type { PlaylistDuplicateResult } from '$lib/types/index';
|
import type { PlaylistDuplicateResult } from '$lib/types/index';
|
||||||
|
|
||||||
export let isOpen = false;
|
interface Props {
|
||||||
export let duplicateResult: PlaylistDuplicateResult | null = null;
|
isOpen: boolean;
|
||||||
export let loading = false;
|
duplicateResult: PlaylistDuplicateResult | null;
|
||||||
|
loading?: boolean;
|
||||||
const dispatch = createEventDispatcher();
|
onAddAll: () => void;
|
||||||
|
onSkipDuplicates: () => void;
|
||||||
function handleAddAll() {
|
onCancel: () => void;
|
||||||
dispatch('addAll');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSkipDuplicates() {
|
let {
|
||||||
dispatch('skipDuplicates');
|
isOpen,
|
||||||
}
|
duplicateResult,
|
||||||
|
loading = false,
|
||||||
function handleCancel() {
|
onAddAll,
|
||||||
dispatch('cancel');
|
onSkipDuplicates,
|
||||||
}
|
onCancel
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
dispatch('cancel');
|
onCancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal {isOpen} onClose={handleClose} title={'You\'ve added some of these tracks before'}>
|
<Modal {isOpen} onClose={handleClose} title={$t('playlist.duplicates.title')}>
|
||||||
{#if duplicateResult}
|
{#if duplicateResult}
|
||||||
<div class="duplicate-info">
|
<div class="duplicate-info">
|
||||||
<p>
|
<p>
|
||||||
This playlist already contains <strong>{duplicateResult.duplicate_count}</strong> of the
|
{$t('playlist.duplicates.description', { values: { duplicateCount: duplicateResult.duplicate_count, totalCount: duplicateResult.total_tracks } })}
|
||||||
track{duplicateResult.duplicate_count !== 1 ? 's' : ''} you're adding.
|
|
||||||
Add only the new ones, or add everything including duplicates ({duplicateResult.total_tracks} track{duplicateResult.total_tracks !== 1 ? 's' : ''}).
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#snippet footer()}
|
{#snippet footer()}
|
||||||
<div class="footer-right">
|
<div class="footer-right">
|
||||||
<button
|
<button
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
on:click={handleAddAll}
|
onclick={onAddAll}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
>
|
||||||
{#if loading}
|
{#if loading}
|
||||||
Adding...
|
{$t('playlist.duplicates.adding')}
|
||||||
{:else}
|
{:else}
|
||||||
Add all tracks
|
{$t('playlist.duplicates.addAll')}
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
on:click={handleSkipDuplicates}
|
onclick={onSkipDuplicates}
|
||||||
disabled={loading || duplicateResult?.duplicate_count === 0}
|
disabled={loading || duplicateResult?.duplicate_count === 0}
|
||||||
>
|
>
|
||||||
{#if loading}
|
{#if loading}
|
||||||
Adding...
|
{$t('playlist.duplicates.adding')}
|
||||||
{:else}
|
{:else}
|
||||||
Add only new tracks
|
{$t('playlist.duplicates.addNew')}
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,4 +83,4 @@
|
|||||||
gap: 12px;
|
gap: 12px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -820,12 +820,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<PlaylistDuplicateConfirmModal
|
<PlaylistDuplicateConfirmModal
|
||||||
bind:isOpen={showDuplicateConfirm}
|
isOpen={showDuplicateConfirm}
|
||||||
bind:duplicateResult={duplicateResult}
|
{duplicateResult}
|
||||||
bind:loading={loading}
|
{loading}
|
||||||
on:addAll={handleDuplicateAddAll}
|
onAddAll={handleDuplicateAddAll}
|
||||||
on:skipDuplicates={handleDuplicateSkipDuplicates}
|
onSkipDuplicates={handleDuplicateSkipDuplicates}
|
||||||
on:cancel={handleDuplicateCancel}
|
onCancel={handleDuplicateCancel}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -271,7 +271,14 @@
|
|||||||
"createNewPlaylist": "Neue Playlist erstellen",
|
"createNewPlaylist": "Neue Playlist erstellen",
|
||||||
"newPlaylist": "Neue Playlist",
|
"newPlaylist": "Neue Playlist",
|
||||||
"editPlaylist": "Playlist bearbeiten",
|
"editPlaylist": "Playlist bearbeiten",
|
||||||
"addToPlaylist": "Zur Playlist hinzufügen"
|
"addToPlaylist": "Zur Playlist hinzufügen",
|
||||||
|
"duplicates": {
|
||||||
|
"title": "Einige dieser Titel wurden bereits hinzugefügt",
|
||||||
|
"description": "Diese Playlist enthält bereits {duplicateCount} der {totalCount} Titel, die du hinzufügst. Füge nur die neuen hinzu oder füge alle einschließlich Duplikate hinzu.",
|
||||||
|
"addAll": "Alle Titel hinzufügen",
|
||||||
|
"addNew": "Nur neue Titel hinzufügen",
|
||||||
|
"adding": "Wird hinzugefügt..."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "Favoriten",
|
"title": "Favoriten",
|
||||||
|
|||||||
@@ -273,7 +273,14 @@
|
|||||||
"hideFromSidebar": "Hide from sidebar",
|
"hideFromSidebar": "Hide from sidebar",
|
||||||
"createAndAdd": "Create & Add",
|
"createAndAdd": "Create & Add",
|
||||||
"playlistWithTracks": "{name} ({count} tracks)",
|
"playlistWithTracks": "{name} ({count} tracks)",
|
||||||
"copyToLibrary": "Copy to library"
|
"copyToLibrary": "Copy to library",
|
||||||
|
"duplicates": {
|
||||||
|
"title": "Some of these tracks were already added",
|
||||||
|
"description": "This playlist already contains {duplicateCount} of the {totalCount} tracks you're adding. Add only the new ones, or add everything including duplicates.",
|
||||||
|
"addAll": "Add all tracks",
|
||||||
|
"addNew": "Add only new tracks",
|
||||||
|
"adding": "Adding..."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"sort": {
|
"sort": {
|
||||||
"nameAZ": "Name (A-Z)",
|
"nameAZ": "Name (A-Z)",
|
||||||
|
|||||||
@@ -273,7 +273,14 @@
|
|||||||
"hideFromSidebar": "Ocultar de la barra lateral",
|
"hideFromSidebar": "Ocultar de la barra lateral",
|
||||||
"createAndAdd": "Crear y Agregar",
|
"createAndAdd": "Crear y Agregar",
|
||||||
"playlistWithTracks": "{name} ({count} pistas)",
|
"playlistWithTracks": "{name} ({count} pistas)",
|
||||||
"copyToLibrary": "Copiar a mi biblioteca"
|
"copyToLibrary": "Copiar a mi biblioteca",
|
||||||
|
"duplicates": {
|
||||||
|
"title": "Algunas de estas pistas ya fueron agregadas",
|
||||||
|
"description": "Esta lista ya contiene {duplicateCount} de las {totalCount} pistas que estás agregando. Agrega solo las nuevas o agrega todas incluyendo duplicadas.",
|
||||||
|
"addAll": "Agregar todas",
|
||||||
|
"addNew": "Agregar solo nuevas",
|
||||||
|
"adding": "Agregando..."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"sort": {
|
"sort": {
|
||||||
"nameAZ": "Nombre (A-Z)",
|
"nameAZ": "Nombre (A-Z)",
|
||||||
|
|||||||
@@ -271,7 +271,14 @@
|
|||||||
"createNewPlaylist": "Créer une nouvelle playlist",
|
"createNewPlaylist": "Créer une nouvelle playlist",
|
||||||
"newPlaylist": "Nouvelle playlist",
|
"newPlaylist": "Nouvelle playlist",
|
||||||
"editPlaylist": "Modifier la playlist",
|
"editPlaylist": "Modifier la playlist",
|
||||||
"addToPlaylist": "Ajouter à la playlist"
|
"addToPlaylist": "Ajouter à la playlist",
|
||||||
|
"duplicates": {
|
||||||
|
"title": "Certaines de ces pistes ont déjà été ajoutées",
|
||||||
|
"description": "Cette playlist contient déjà {duplicateCount} des {totalCount} pistes que vous ajoutez. Ajoutez uniquement les nouvelles ou ajoutez tout y compris les doublons.",
|
||||||
|
"addAll": "Ajouter toutes les pistes",
|
||||||
|
"addNew": "Ajouter uniquement les nouvelles",
|
||||||
|
"adding": "Ajout en cours..."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"title": "Favoris",
|
"title": "Favoris",
|
||||||
|
|||||||
Reference in new issue
Block a user