mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(web): remove buffer package (#11058)
This commit is contained in:
parent
1b3a7feb67
commit
5748f50c1f
5 changed files with 29 additions and 47 deletions
|
|
@ -0,0 +1,24 @@
|
|||
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
|
||||
import { render } from '@testing-library/svelte';
|
||||
|
||||
describe('ImageThumbnail component', () => {
|
||||
beforeAll(() => {
|
||||
Object.defineProperty(HTMLImageElement.prototype, 'decode', {
|
||||
value: vi.fn(),
|
||||
});
|
||||
});
|
||||
|
||||
it('shows thumbhash while image is loading', () => {
|
||||
const sut = render(ImageThumbnail, {
|
||||
url: 'http://localhost/img.png',
|
||||
altText: 'test',
|
||||
thumbhash: '1QcSHQRnh493V4dIh4eXh1h4kJUI',
|
||||
widthStyle: '250px',
|
||||
});
|
||||
|
||||
const [_, thumbhash] = sut.getAllByRole('img');
|
||||
expect(thumbhash.getAttribute('src')).toContain(
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAgCAYAAAD5VeO1AAAMRklEQVR4AQBdAKL/', // truncated
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
<script lang="ts">
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { decodeBase64 } from '$lib/utils';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { thumbHashToDataURL } from 'thumbhash';
|
||||
// eslint-disable-next-line unicorn/prefer-node-protocol
|
||||
import { Buffer } from 'buffer';
|
||||
import { mdiEyeOffOutline } from '@mdi/js';
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
|
||||
|
|
@ -62,7 +61,7 @@
|
|||
<img
|
||||
style:width={widthStyle}
|
||||
style:height={heightStyle}
|
||||
src={thumbHashToDataURL(Buffer.from(thumbhash, 'base64'))}
|
||||
src={thumbHashToDataURL(decodeBase64(thumbhash))}
|
||||
alt={altText}
|
||||
{title}
|
||||
class="absolute top-0 object-cover"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue