diff --git a/README.md b/README.md index 86dc53a..0518573 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ Wallpapers are picked randomly or in order in an interval depending on your choi - 3 different wallpaper modes (stretched, centered & cropped) ### Changelog + +#### v2.0.2: +- **Bugfix:** Only the first 100 files were detected in a folder + #### v2.0.1: - **Bugfix:** Visual inconsistency diff --git a/js/FilesystemManager.js b/js/FilesystemManager.js index dd159de..ee98313 100644 --- a/js/FilesystemManager.js +++ b/js/FilesystemManager.js @@ -19,30 +19,50 @@ async function getRoot() { } async function readFolderContent(entry) { - return new Promise((resolve, reject) => { - entry.createReader().readEntries( + const reader = entry.createReader(); + + const ret = await recurseReadFolderContent(reader); + + ret.images = ret.images.sort((a, b) => a.name.localeCompare(b.name)); + + return ret; +} + +async function recurseReadFolderContent(reader) { + return new Promise(async (resolve, reject) => { + const arrImages = []; + const arrSkipped = []; + + reader.readEntries( async result => { - const arrImages = []; - const arrSkipped = []; - - for (const entry of result) { - if (entry.isDirectory) { - const contentSubfolder = await readFolderContent(entry); - arrImages.push(...contentSubfolder.images); - arrSkipped.push(...contentSubfolder.skipped); - } else { - if (_isAllowedImage(entry)) { - arrImages.push(entry); + if (result.length == 0) { + resolve({ + images: [], + skipped: [] + }); + return; + } else { + for (const entry of result) { + if (entry.isDirectory) { + const contentSubfolder = await recurseReadFolderContent(entry.createReader()); + arrImages.push(...contentSubfolder.images); + arrSkipped.push(...contentSubfolder.skipped); } else { - arrSkipped.push(entry); + if (_isAllowedImage(entry)) { + arrImages.push(entry); + } else { + arrSkipped.push(entry); + } } } + const folderContent = await recurseReadFolderContent(reader); + arrImages.push(...folderContent.images); + arrSkipped.push(...folderContent.skipped); + resolve({ + images: arrImages, + skipped: arrSkipped + }); } - - resolve({ - images: arrImages, - skipped: arrSkipped - }); }, async err => { NotificationManager.show( diff --git a/manifest.json b/manifest.json index 7ebd707..3aff3c3 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "__MSG_app_name__", "short_name": "__MSG_app_short_name__", "description": "__MSG_app_description__", - "version": "2.0.1", + "version": "2.0.2", "minimum_chrome_version": "38", "default_locale": "en", "icons": {