mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
feat: add selected background to background migration
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
import base64ToBlob from './base64ToBlob';
|
import base64ToBlob from './base64ToBlob';
|
||||||
import { delay } from './delay';
|
|
||||||
import { openDatabase, writeData } from '@/interface/hooks/BackgroundDataLoader';
|
import { openDatabase, writeData } from '@/interface/hooks/BackgroundDataLoader';
|
||||||
import { backgroundUpdates } from '@/interface/hooks/BackgroundUpdates';
|
import { backgroundUpdates } from '@/interface/hooks/BackgroundUpdates';
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ export const migrateBackgrounds = async (): Promise<void> => {
|
|||||||
|
|
||||||
case 'BACKGROUND_DATA':
|
case 'BACKGROUND_DATA':
|
||||||
try {
|
try {
|
||||||
const { id, data, mediaType, total, processed } = event.data.payload;
|
const { id, data, mediaType, total, processed, isSelected } = event.data.payload;
|
||||||
const mimeType = mediaType === 'image' ? 'image/png' : 'video/mp4';
|
const mimeType = mediaType === 'image' ? 'image/png' : 'video/mp4';
|
||||||
const blob = base64ToBlob(data, mimeType);
|
const blob = base64ToBlob(data, mimeType);
|
||||||
|
|
||||||
@@ -53,6 +52,10 @@ export const migrateBackgrounds = async (): Promise<void> => {
|
|||||||
type: mediaType
|
type: mediaType
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isSelected) {
|
||||||
|
localStorage.setItem('selectedBackground', id);
|
||||||
|
}
|
||||||
|
|
||||||
migrationState.lastProcessedId = id;
|
migrationState.lastProcessedId = id;
|
||||||
migrationState.total = total;
|
migrationState.total = total;
|
||||||
migrationState.processed = processed;
|
migrationState.processed = processed;
|
||||||
|
|||||||
@@ -37,10 +37,15 @@ const getAllBackgrounds = async (): Promise<Data[]> => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSelectedBackground = (): string | null => {
|
||||||
|
return localStorage.getItem('selectedBackground');
|
||||||
|
};
|
||||||
|
|
||||||
const startMigration = async () => {
|
const startMigration = async () => {
|
||||||
try {
|
try {
|
||||||
console.info('Starting background extraction...');
|
console.info('Starting background extraction...');
|
||||||
const backgrounds = await getAllBackgrounds();
|
const backgrounds = await getAllBackgrounds();
|
||||||
|
const selectedBackground = getSelectedBackground();
|
||||||
console.info(`Found ${backgrounds.length} backgrounds`);
|
console.info(`Found ${backgrounds.length} backgrounds`);
|
||||||
|
|
||||||
window.parent.postMessage({ type: 'GET_LAST_PROCESSED_ID' }, '*');
|
window.parent.postMessage({ type: 'GET_LAST_PROCESSED_ID' }, '*');
|
||||||
@@ -72,7 +77,8 @@ const startMigration = async () => {
|
|||||||
data: base64Data,
|
data: base64Data,
|
||||||
mediaType: background.type,
|
mediaType: background.type,
|
||||||
total: backgrounds.length,
|
total: backgrounds.length,
|
||||||
processed: i + 1
|
processed: i + 1,
|
||||||
|
isSelected: background.id === selectedBackground
|
||||||
}
|
}
|
||||||
}, '*');
|
}, '*');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user