mirror of
https://github.com/mue/mue.git
synced 2026-07-17 22:14:13 +02:00
fix: use AVIF if supported
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
|
||||
import './scss/index.scss';
|
||||
import { decodeBlurHash } from 'fast-blurhash';
|
||||
import { supportsAVIF } from 'modules/helpers/background/avif';
|
||||
|
||||
export default class Background extends PureComponent {
|
||||
constructor() {
|
||||
@@ -177,8 +178,9 @@ export default class Background extends PureComponent {
|
||||
break;
|
||||
}
|
||||
|
||||
const accept = 'application/json, ' + (await supportsAVIF() ? 'image/avif' : 'image/webp');
|
||||
try {
|
||||
data = await (await fetch(requestURL)).json();
|
||||
data = await (await fetch(requestURL, { headers: { accept } })).json();
|
||||
} catch (e) {
|
||||
// if requesting to the API fails, we get an offline image
|
||||
return this.setState(offlineBackground('api'));
|
||||
|
||||
Reference in New Issue
Block a user