fix: background migration not working properly

This commit is contained in:
SethBurkart123
2024-11-27 09:22:34 +11:00
parent 96cf8e3eac
commit 6c93477998
3 changed files with 22 additions and 9 deletions
+17 -1
View File
@@ -44,7 +44,23 @@ const getSelectedBackground = (): string | null => {
const startMigration = async () => {
try {
console.info('Starting background extraction...');
const backgrounds = await getAllBackgrounds();
let backgrounds: Data[];
try {
backgrounds = await getAllBackgrounds();
if (!backgrounds || backgrounds.length === 0) {
console.info('No backgrounds to migrate');
window.parent.postMessage({ type: 'MIGRATION_COMPLETE' }, '*');
return;
}
} catch (error: any) {
if (error.name === 'NotFoundError' && error.message.includes('object stores was not found')) {
console.info('No backgrounds to migrate: object store not found');
window.parent.postMessage({ type: 'MIGRATION_COMPLETE' }, '*');
return;
}
console.error('Error fetching backgrounds:', error);
throw new Error('Failed to fetch backgrounds');
}
const selectedBackground = getSelectedBackground();
console.info(`Found ${backgrounds.length} backgrounds`);