feat: enhance BackgroundImageSelector with custom image management
- Removed preserved custom URL handling and replaced it with a custom images array for better management of user-added backgrounds. - Updated the component to allow adding, selecting, and removing custom images, improving user experience and flexibility. - Adjusted background cycling logic to include custom images, ensuring a seamless integration with existing backgrounds.
This commit is contained in:
@@ -23,23 +23,17 @@ export function useBackgroundCycle() {
|
||||
|
||||
const cycleBackground = () => {
|
||||
const currentBackground = preferences?.viewPreferences?.backgroundImage;
|
||||
const customImages = preferences?.viewPreferences?.customImages || [];
|
||||
|
||||
// Construire la liste complète des backgrounds (prédéfinis + personnalisé)
|
||||
// Construire la liste complète des backgrounds (prédéfinis + personnalisés)
|
||||
const allBackgrounds = [...BACKGROUND_CYCLE];
|
||||
|
||||
// Ajouter l'image personnalisée préservée si elle existe
|
||||
const preservedCustomUrl = localStorage.getItem('preservedCustomBackground');
|
||||
|
||||
if (preservedCustomUrl && !BACKGROUND_CYCLE.includes(preservedCustomUrl)) {
|
||||
allBackgrounds.push(preservedCustomUrl);
|
||||
}
|
||||
|
||||
// Ajouter aussi l'image actuelle si elle est personnalisée ET différente de celle préservée
|
||||
if (currentBackground &&
|
||||
!BACKGROUND_CYCLE.includes(currentBackground) &&
|
||||
currentBackground !== preservedCustomUrl) {
|
||||
allBackgrounds.push(currentBackground);
|
||||
}
|
||||
// Ajouter toutes les images personnalisées
|
||||
customImages.forEach(url => {
|
||||
if (!allBackgrounds.includes(url)) {
|
||||
allBackgrounds.push(url);
|
||||
}
|
||||
});
|
||||
|
||||
const currentIndex = allBackgrounds.findIndex(bg => bg === currentBackground);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user