2022-07-15 23:18:17 -05:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { api, UserResponseDto } from '@api';
|
|
|
|
|
|
|
|
|
|
export let user: UserResponseDto;
|
|
|
|
|
|
2022-07-22 09:44:22 -05:00
|
|
|
// Avatar Size In Pixel
|
|
|
|
|
export let size: number = 48;
|
|
|
|
|
|
2022-07-15 23:18:17 -05:00
|
|
|
const getUserAvatar = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await api.userApi.getProfileImage(user.id, {
|
|
|
|
|
responseType: 'blob'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (data instanceof Blob) {
|
|
|
|
|
return URL.createObjectURL(data);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return '/favicon.png';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#await getUserAvatar()}
|
2022-07-22 09:44:22 -05:00
|
|
|
<div
|
|
|
|
|
style:width={`${size}px`}
|
|
|
|
|
style:height={`${size}px`}
|
|
|
|
|
class={` rounded-full bg-immich-primary/25`}
|
|
|
|
|
/>
|
2022-07-15 23:18:17 -05:00
|
|
|
{:then data}
|
|
|
|
|
<img
|
|
|
|
|
src={data}
|
|
|
|
|
alt="profile-img"
|
2022-07-22 09:44:22 -05:00
|
|
|
style:width={`${size}px`}
|
|
|
|
|
style:height={`${size}px`}
|
|
|
|
|
class={`inline rounded-full object-cover border shadow-md`}
|
2022-07-15 23:18:17 -05:00
|
|
|
title={user.email}
|
|
|
|
|
/>
|
|
|
|
|
{/await}
|