diff --git a/src/components/Background.jsx b/src/components/Background.jsx index 1ee23a1c..ed5e2ca6 100644 --- a/src/components/Background.jsx +++ b/src/components/Background.jsx @@ -14,7 +14,9 @@ export default class Background extends React.Component { const photo = Math.floor(Math.random() * (20 - 1 + 1)) + 1; // There are 20 images in the offline-images folder document.getElementById('backgroundCredits').style.display = 'none'; // Hide the location icon let photographer; // Photographer credit - switch (photo) { // Select photographer based on image file number + let pixabayNumbers = [2, 3, 9, 11, 13, 14, 15]; // As there are a lot of Pixabay photos, we shorten the code a bit here + if (pixabayNumbers.includes(photo)) photographer = 'Pixabay'; + else switch (photo) { default: { photographer = 'Unknown'; break; @@ -23,14 +25,6 @@ export default class Background extends React.Component { photographer = 'Tirachard Kumtanom'; break; } - case 2: { - photographer = 'Pixabay'; - break; - } - case 3: { - photographer = 'Pixabay'; - break; - } case 4: { photographer = 'Sohail Na'; break; @@ -39,30 +33,10 @@ export default class Background extends React.Component { photographer = 'Miriam Espacio'; break; } - case 9: { - photographer = 'Pixabay'; - break; - } case 10: { photographer = 'NO NAME'; break; } - case 11: { - photographer = 'Pixabay'; - break; - } - case 13: { - photographer = 'Pixabay'; - break; - } - case 14: { - photographer = 'Pixabay'; - break; - } - case 15: { - photographer = 'Pixabay'; - break; - } case 20: { photographer = 'Fabian Wiktor'; break; diff --git a/src/components/Quote.jsx b/src/components/Quote.jsx index 68412ba8..c482c5bf 100644 --- a/src/components/Quote.jsx +++ b/src/components/Quote.jsx @@ -15,6 +15,13 @@ export default class Quote extends React.Component { try { // First we try and get a quote from the API... let data = await fetch('https://api.muetab.xyz/getQuote'); data = await data.json(); + if (data.statusCode === 429) { // If we hit the ratelimit, we fallback to local quotes + const quote = Quotes.random(); // Get a random quote from our local package + return this.setState({ + quote: quote.quote, + author: quote.author + }); // Set the quote + } this.setState({ quote: data.quote, author: data.author