1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-06 21:48:30 -04:00

feat(wallpaper): support random cycling order (#2936)

This commit is contained in:
Huỳnh Thiện Lộc
2026-08-05 08:21:52 +07:00
committed by GitHub
parent 158c0c12d8
commit 99b0dc596d
5 changed files with 114 additions and 4 deletions
@@ -231,11 +231,28 @@ Singleton {
if (currentIndex === -1)
currentIndex = 0;
let targetIndex;
if (goToPrevious) {
targetIndex = currentIndex === 0 ? wallpaperList.length - 1 : currentIndex - 1;
let isRandom = false;
if (targetScreenName) {
isRandom = !!SessionData.getMonitorCyclingSettings(targetScreenName).random;
} else {
targetIndex = (currentIndex + 1) % wallpaperList.length;
isRandom = !!SessionData.wallpaperCyclingRandom;
}
let targetIndex;
if (isRandom) {
if (wallpaperList.length > 1) {
do {
targetIndex = Math.floor(Math.random() * wallpaperList.length);
} while (targetIndex === currentIndex);
} else {
targetIndex = 0;
}
} else {
if (goToPrevious) {
targetIndex = currentIndex === 0 ? wallpaperList.length - 1 : currentIndex - 1;
} else {
targetIndex = (currentIndex + 1) % wallpaperList.length;
}
}
const targetWallpaper = wallpaperList[targetIndex];
if (!targetWallpaper || targetWallpaper === currentPath)