Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ciriousjoker committed Feb 24, 2022
1 parent a4e5810 commit 3013a11
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
58 changes: 39 additions & 19 deletions js/FilesystemManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 3013a11

Please sign in to comment.