Lazy-load the Gameboy component
This commit is contained in:
parent
f7c624483e
commit
0bb50f492e
|
@ -69,4 +69,4 @@ const WasmBoyOptions = {
|
||||||
saveStateCallback: false,
|
saveStateCallback: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export { Gameboy };
|
export default Gameboy;
|
|
@ -1,5 +1,5 @@
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React, { useState, useRef, useLayoutEffect } from 'react';
|
import React, { useState, useRef, useLayoutEffect, Suspense } from 'react';
|
||||||
|
|
||||||
import Blurhash from 'soapbox/components/blurhash';
|
import Blurhash from 'soapbox/components/blurhash';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
@ -12,11 +12,11 @@ import { truncateFilename } from 'soapbox/utils/media';
|
||||||
import { isIOS } from '../is-mobile';
|
import { isIOS } from '../is-mobile';
|
||||||
import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maximumAspectRatio } from '../utils/media-aspect-ratio';
|
import { isPanoramic, isPortrait, isNonConformingRatio, minimumAspectRatio, maximumAspectRatio } from '../utils/media-aspect-ratio';
|
||||||
|
|
||||||
import { Gameboy } from './gameboy';
|
|
||||||
|
|
||||||
import type { Property } from 'csstype';
|
import type { Property } from 'csstype';
|
||||||
import type { List as ImmutableList } from 'immutable';
|
import type { List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
|
const Gameboy = React.lazy(() => import('./gameboy'));
|
||||||
|
|
||||||
const ATTACHMENT_LIMIT = 4;
|
const ATTACHMENT_LIMIT = 4;
|
||||||
const MAX_FILENAME_LENGTH = 45;
|
const MAX_FILENAME_LENGTH = 45;
|
||||||
|
|
||||||
|
@ -155,7 +155,9 @@ const Item: React.FC<IItem> = ({
|
||||||
key={attachment.id}
|
key={attachment.id}
|
||||||
style={{ position, float, left, top, right, bottom, height, width: `${width}%` }}
|
style={{ position, float, left, top, right, bottom, height, width: `${width}%` }}
|
||||||
>
|
>
|
||||||
|
<Suspense fallback={<div className='media-gallery__item-thumbnail' />}>
|
||||||
<Gameboy className='media-gallery__item-thumbnail object-contain' src={attachment.url} />
|
<Gameboy className='media-gallery__item-thumbnail object-contain' src={attachment.url} />
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (attachment.type === 'unknown') {
|
} else if (attachment.type === 'unknown') {
|
||||||
|
|
Loading…
Reference in New Issue