Remove no longer needed cookie code

This commit is contained in:
David Ralph
2019-10-20 21:27:18 +01:00
parent 5be47d798b
commit 9f21ffe5f0

View File

@@ -1,11 +1,6 @@
import React from 'react';
import Fetch from 'unfetch';
const getCookie = (cookiename) => {
const cookiestring = RegExp('' + cookiename + '[^;]+').exec(document.cookie);
return unescape(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./,'') : '');
};
const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; };
export default class Background extends React.Component {
@@ -17,18 +12,9 @@ export default class Background extends React.Component {
let data = await Fetch('https://api.muetab.xyz/getImage?category=Outdoors');
data = await data.json();
const checkRepeat = getCookie('backgroundimageurl');
root.style.backgroundImage = `url(${data.file})`;
document.getElementById('photographer').innerText = `Photo by ${data.photographer}`;
document.getElementById('location').innerText = `${data.location}`;
if (checkRepeat !== root.style.backgroundImage) root.style.backgroundImage = `url(${data.file})`;
else {
/*let data = await Fetch('https://api.muetab.xyz/getImage?category=Outdoors');
data = await data.json();*/
document.cookie = 'backgroundimageurl; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
root.style.backgroundImage = `url(${data.file})`;
document.cookie = `backgroundimageurl=${data.file}`;
}
document.getElementById('location').innerText = `${data.location}`;
} catch (e) {
document.getElementById('backgroundCredits').style.display = 'none';
document.getElementById('photographer').innerText = 'Photo from Pexels';