@@ -42,7 +42,7 @@ import {
4242 preloadImage ,
4343} from "utils/functions" ;
4444
45- const slideshowFiles : string [ ] = [ ] ;
45+ let slideshowFiles : Record < string , string [ ] > = { } ;
4646
4747const useWallpaper = (
4848 desktopRef : React . RefObject < HTMLElement | null >
@@ -288,22 +288,26 @@ const useWallpaper = (
288288 updateFolder ( PICTURES_FOLDER , SLIDESHOW_FILE ) ;
289289 }
290290
291- if ( slideshowFiles . length === 0 ) {
292- slideshowFiles . push (
291+ slideshowFiles = {
292+ [ wallpaperImage ] : slideshowFiles [ wallpaperImage ] || [ ] ,
293+ } ;
294+
295+ if ( slideshowFiles [ wallpaperImage ] . length === 0 ) {
296+ slideshowFiles [ wallpaperImage ] . push (
293297 ...[
294298 ...new Set (
295299 JSON . parse (
296300 ( await readFile ( slideshowFilePath ) ) ?. toString ( ) || "[]"
297301 ) as string [ ]
298302 ) ,
299- ] . sort ( ( ) => Math . random ( ) - ( isAlt ? 0.5 : - 0.5 ) )
303+ ] . sort ( ( ) => Math . random ( ) - 0.5 )
300304 ) ;
301305 }
302306
303307 do {
304- wallpaperUrl = slideshowFiles . shift ( ) || "" ;
308+ wallpaperUrl = slideshowFiles [ wallpaperImage ] . shift ( ) || "" ;
305309
306- const [ nextWallpaper ] = slideshowFiles ;
310+ const [ nextWallpaper ] = slideshowFiles [ wallpaperImage ] ;
307311
308312 if ( nextWallpaper ) {
309313 document . querySelector ( `#${ PRELOAD_ID } ` ) ?. remove ( ) ;
@@ -322,7 +326,7 @@ const useWallpaper = (
322326 }
323327 } while (
324328 currentWallpaperUrl === wallpaperUrl &&
325- slideshowFiles . length > 1
329+ slideshowFiles [ wallpaperImage ] . length > 1
326330 ) ;
327331
328332 newWallpaperFit = "fill" ;
0 commit comments