mirror of
https://github.com/mue/mue.git
synced 2026-06-11 19:18:57 +02:00
fix: background marketplace interval
This commit is contained in:
@@ -250,14 +250,17 @@ export default class Background extends PureComponent {
|
||||
}
|
||||
});
|
||||
if (photoPack) {
|
||||
const randomNumber = Math.floor(Math.random() * photoPack.length)
|
||||
const randomNumber = Math.floor(Math.random() * photoPack.length);
|
||||
const randomPhoto = photoPack[randomNumber];
|
||||
if (
|
||||
localStorage.getItem('backgroundchange') === 'refresh' ||
|
||||
localStorage.getItem('backgroundchange') === null
|
||||
(localStorage.getItem('backgroundchange') === 'refresh' && this.state.firstTime === true) ||
|
||||
(localStorage.getItem('backgroundchange') === null && this.state.firstTime === true)
|
||||
) {
|
||||
localStorage.setItem('marketplaceNumber', randomNumber)
|
||||
return this.setState({
|
||||
localStorage.setItem('marketplaceNumber', randomNumber);
|
||||
console.log("APPLE BOTTOM JEANS")
|
||||
console.log(this.state.firstTime)
|
||||
this.setState({ firstTime: false })
|
||||
this.setState({
|
||||
url: randomPhoto.url.default,
|
||||
type: 'photo_pack',
|
||||
photoInfo: {
|
||||
@@ -267,38 +270,40 @@ export default class Background extends PureComponent {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
if (
|
||||
Number(
|
||||
Number(localStorage.getItem('backgroundStartTime')) +
|
||||
Number(localStorage.getItem('backgroundchange')) >=
|
||||
Number(Date.now()),
|
||||
)
|
||||
) {
|
||||
{/*}
|
||||
const randomPhoto = photoPack[localStorage.getItem('marketplaceNumber')];
|
||||
return this.setState({
|
||||
url: randomPhoto.url.default,
|
||||
type: 'photo_pack',
|
||||
photoInfo: {
|
||||
hidden: false,
|
||||
credit: randomPhoto.photographer,
|
||||
location: randomPhoto.location || 'N/A',
|
||||
},
|
||||
});
|
||||
*/}
|
||||
break;
|
||||
} else {
|
||||
localStorage.setItem('marketplaceNumber', randomNumber)
|
||||
return this.setState({
|
||||
url: randomPhoto.url.default,
|
||||
type: 'photo_pack',
|
||||
photoInfo: {
|
||||
hidden: false,
|
||||
credit: randomPhoto.photographer,
|
||||
location: randomPhoto.location || 'N/A',
|
||||
},
|
||||
});
|
||||
}
|
||||
if (
|
||||
Number(
|
||||
Number(localStorage.getItem('backgroundStartTime')) +
|
||||
Number(localStorage.getItem('backgroundchange')) >=
|
||||
Number(Date.now()),
|
||||
)
|
||||
) {
|
||||
const randomPhoto = photoPack[localStorage.getItem('marketplaceNumber')];
|
||||
if (this.state.firstTime !== true) {
|
||||
this.setState({
|
||||
url: randomPhoto.url.default,
|
||||
type: 'photo_pack',
|
||||
photoInfo: {
|
||||
hidden: false,
|
||||
credit: randomPhoto.photographer,
|
||||
location: randomPhoto.location || 'N/A',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.setState({ firstTime: true });
|
||||
}
|
||||
this.setState({ firstTime: true });
|
||||
} else {
|
||||
localStorage.setItem('marketplaceNumber', randomNumber);
|
||||
return this.setState({
|
||||
url: randomPhoto.url.default,
|
||||
type: 'photo_pack',
|
||||
photoInfo: {
|
||||
hidden: false,
|
||||
credit: randomPhoto.photographer,
|
||||
location: randomPhoto.location || 'N/A',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -335,6 +335,30 @@ export default class Quote extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const test = localStorage.getItem('quotechange')
|
||||
|
||||
this.interval = setInterval(() => {
|
||||
if (test !== null ) {
|
||||
const targetTime = Number(
|
||||
Number(localStorage.getItem('quoteStartTime')) +
|
||||
Number(localStorage.getItem('quotechange')),
|
||||
);
|
||||
const currentTime = Number(Date.now());
|
||||
if (currentTime >= targetTime) {
|
||||
this.setZoom();
|
||||
this.getQuote();
|
||||
localStorage.setItem('quoteStartTime', Date.now());
|
||||
} else {
|
||||
console.log(localStorage.getItem('quotechange'));
|
||||
try {
|
||||
this.setState(JSON.parse(localStorage.getItem('currentQuote')));
|
||||
} catch (e) {
|
||||
this.setZoom();
|
||||
this.getQuote();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
EventBus.on('refresh', (data) => {
|
||||
if (data === 'quote') {
|
||||
if (localStorage.getItem('quote') === 'false') {
|
||||
@@ -367,31 +391,6 @@ export default class Quote extends PureComponent {
|
||||
this.getQuote();
|
||||
localStorage.setItem('quoteStartTime', Date.now());
|
||||
}
|
||||
|
||||
const test = localStorage.getItem('quotechange')
|
||||
|
||||
this.interval = setInterval(() => {
|
||||
if (test !== null ) {
|
||||
const targetTime = Number(
|
||||
Number(localStorage.getItem('quoteStartTime')) +
|
||||
Number(localStorage.getItem('quotechange')),
|
||||
);
|
||||
const currentTime = Number(Date.now());
|
||||
if (currentTime >= targetTime) {
|
||||
this.setZoom();
|
||||
this.getQuote();
|
||||
localStorage.setItem('quoteStartTime', Date.now());
|
||||
} else {
|
||||
console.log(localStorage.getItem('quotechange'));
|
||||
try {
|
||||
this.setState(JSON.parse(localStorage.getItem('currentQuote')));
|
||||
} catch (e) {
|
||||
this.setZoom();
|
||||
this.getQuote();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
Reference in New Issue
Block a user