reddit-wallpapers
Advanced tools
Comparing version 0.0.3 to 0.0.4
17
index.js
@@ -16,3 +16,3 @@ import { | ||
loops: [], | ||
index: parseInt(localStorage.redWallIndex) || 0, | ||
index: parseInt(localStorage.redWallIndex) - 1 || 0, | ||
previousChoice: undefined | ||
@@ -42,8 +42,9 @@ } | ||
new Promise((resolve, reject) => { | ||
fetch(link).then((resp) => { | ||
setTimeout(() => reject( | ||
self.options.defaultImg === '' ? new Error('reddit request took too long, timed out') : setImage(true) | ||
), self.options.timeout) | ||
fetch(link) | ||
.then((resp) => { | ||
setTimeout(() => reject(false), self.options.timeout) | ||
return resp.json() | ||
}).then((json) => resolve(json)).catch((err) => self.options.defaultImg === '' ? console.warn(err) : setImage(true)) | ||
}) | ||
.then((json) => resolve(json)) | ||
.catch((err) => reject(false)) | ||
}).then((d) => { | ||
@@ -59,2 +60,4 @@ self.data = d.data.children | ||
function setImage(defaultImage=false) { | ||
localStorage.redWallIndex = self.index + 1 | ||
self.index += 1 | ||
if (self.index >= self.data.length - 1 && !defaultImage) { | ||
@@ -96,4 +99,2 @@ self.restart() // clearing loops and reinit | ||
}) | ||
localStorage.redWallIndex = self.index + 1 | ||
self.index += 1 | ||
} | ||
@@ -100,0 +101,0 @@ } |
{ | ||
"name": "reddit-wallpapers", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "to help fetching wallpapers with reddit api and loop setting them", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
324695