feat: add automatic migration dialog for legacy downloads
Implement user-consent migration system for legacy numeric-named FLAC files: - Create MigrationModal component with progress tracking - Auto-detect legacy downloads on settings mount - Show modal with migration details and consent dialog - Real-time progress updates via Tauri events - Display success/failure stats after migration - Refresh library and stats after completion cc
This commit is contained in:
1 parent
0da14a1b23
commit
11d263a2bf
2 files changed
+395
No files matched your search
@@ -27,6 +27,7 @@
|
||||
} from '$lib/services/playbackService';
|
||||
import { setLocale, locale, t } from '$lib/i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import MigrationModal from '../MigrationModal.svelte';
|
||||
|
||||
interface Props {
|
||||
onBack?: () => void;
|
||||
@@ -68,6 +69,10 @@
|
||||
// Lyrics cache state
|
||||
let isClearingLyrics = $state(false);
|
||||
|
||||
// Migration state
|
||||
let showMigrationModal = $state(false);
|
||||
let legacyTracksCount = $state(0);
|
||||
|
||||
// Audio device state
|
||||
let audioDevices = $state<AudioDevice[]>([]);
|
||||
let pipewireSinks = $state<PipewireSink[]>([]);
|
||||
@@ -257,6 +262,9 @@
|
||||
toastsEnabled = getToastsEnabled();
|
||||
loadSystemNotificationsPreference();
|
||||
systemNotificationsEnabled = getSystemNotificationsEnabled();
|
||||
|
||||
// Check for legacy downloads
|
||||
checkLegacyDownloads();
|
||||
});
|
||||
|
||||
async function loadLastfmState() {
|
||||
@@ -680,6 +688,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function checkLegacyDownloads() {
|
||||
try {
|
||||
const result = await invoke<{has_legacy_files: boolean, total_tracks: number}>('detect_legacy_downloads');
|
||||
if (result.has_legacy_files && result.total_tracks > 0) {
|
||||
legacyTracksCount = result.total_tracks;
|
||||
showMigrationModal = true;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to check for legacy downloads:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function closeMigrationModal() {
|
||||
showMigrationModal = false;
|
||||
// Refresh stats after migration
|
||||
loadDownloadStats();
|
||||
}
|
||||
|
||||
async function handleChangeDownloadFolder() {
|
||||
try {
|
||||
const { open } = await import('@tauri-apps/plugin-dialog');
|
||||
@@ -1896,3 +1922,9 @@
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
|
||||
<MigrationModal
|
||||
isOpen={showMigrationModal}
|
||||
onClose={closeMigrationModal}
|
||||
totalTracks={legacyTracksCount}
|
||||
/>
|
||||
Reference in new issue
Block a user