circle-avatar.svelte 657 B

12345678910111213141516171819202122232425262728293031
  1. <script lang="ts">
  2. import { api, UserResponseDto } from '@api';
  3. import { onMount } from 'svelte';
  4. export let user: UserResponseDto;
  5. const getUserAvatar = async () => {
  6. try {
  7. const { data } = await api.userApi.getProfileImage(user.id, {
  8. responseType: 'blob'
  9. });
  10. if (data instanceof Blob) {
  11. return URL.createObjectURL(data);
  12. }
  13. } catch (e) {
  14. return '/favicon.png';
  15. }
  16. };
  17. </script>
  18. {#await getUserAvatar()}
  19. <div class="w-12 h-12 rounded-full bg-immich-primary/25" />
  20. {:then data}
  21. <img
  22. src={data}
  23. alt="profile-img"
  24. class="inline rounded-full w-12 h-12 object-cover border shadow-md"
  25. title={user.email}
  26. />
  27. {/await}