mirror of
https://github.com/mue/mue.git
synced 2026-06-11 02:59:06 +02:00
fix: background refresh spam effects issue
This commit is contained in:
@@ -6,7 +6,6 @@ import { PureComponent } from 'react';
|
||||
import PhotoInformation from './PhotoInformation';
|
||||
|
||||
import EventBus from 'modules/helpers/eventbus';
|
||||
import Interval from 'modules/helpers/interval';
|
||||
import {
|
||||
videoCheck,
|
||||
offlineBackground,
|
||||
@@ -92,7 +91,6 @@ export default class Background extends PureComponent {
|
||||
}
|
||||
|
||||
const setFavourited = ({ type, url, credit, location, camera }) => {
|
||||
console.log(type);
|
||||
if (type === 'random_colour' || type === 'random_gradient') {
|
||||
return this.setState({
|
||||
type: 'colour',
|
||||
@@ -118,7 +116,7 @@ export default class Background extends PureComponent {
|
||||
switch (type) {
|
||||
case 'api':
|
||||
if (offline) {
|
||||
return this.setState(offlineBackground());
|
||||
return this.setState(offlineBackground('api'));
|
||||
}
|
||||
|
||||
// API background
|
||||
@@ -145,7 +143,7 @@ export default class Background extends PureComponent {
|
||||
data = await (await fetch(requestURL)).json();
|
||||
} catch (e) {
|
||||
// if requesting to the API fails, we get an offline image
|
||||
return this.setState(offlineBackground());
|
||||
return this.setState(offlineBackground('api'));
|
||||
}
|
||||
|
||||
let photoURL, photographerURL;
|
||||
@@ -210,7 +208,7 @@ export default class Background extends PureComponent {
|
||||
|
||||
// allow users to use offline images
|
||||
if (offline && !customBackground.startsWith('data:')) {
|
||||
return this.setState(offlineBackground());
|
||||
return this.setState(offlineBackground('custom'));
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -235,7 +233,7 @@ export default class Background extends PureComponent {
|
||||
|
||||
case 'photo_pack':
|
||||
if (offline) {
|
||||
return this.setState(offlineBackground());
|
||||
return this.setState(offlineBackground('photo_pack'));
|
||||
}
|
||||
|
||||
const photofavourited = JSON.parse(localStorage.getItem('favourite'));
|
||||
|
||||
@@ -9,7 +9,7 @@ export function videoCheck(url) {
|
||||
);
|
||||
}
|
||||
|
||||
export function offlineBackground() {
|
||||
export function offlineBackground(type) {
|
||||
// Get all photographers from the keys in offlineImages.json
|
||||
const photographers = Object.keys(offlineImages);
|
||||
const photographer = photographers[Math.floor(Math.random() * photographers.length)];
|
||||
@@ -21,6 +21,7 @@ export function offlineBackground() {
|
||||
|
||||
const object = {
|
||||
url: `./offline-images/${randomImage}.webp`,
|
||||
type,
|
||||
photoInfo: {
|
||||
offline: true,
|
||||
credit: photographer,
|
||||
|
||||
Reference in New Issue
Block a user