25 lines
560 B
Vue
25 lines
560 B
Vue
<template>
|
|
<span class="account-avatar" aria-hidden="true">
|
|
<img
|
|
v-if="user?.picture && !failed"
|
|
:src="user.picture"
|
|
alt=""
|
|
@error="failed = true"
|
|
/>
|
|
<template v-else>{{
|
|
(user?.username || "?").slice(0, 1).toUpperCase()
|
|
}}</template>
|
|
</span>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { ref, watch } from "vue";
|
|
const props = defineProps<{
|
|
user: { picture?: string; username?: string } | null;
|
|
}>();
|
|
const failed = ref(false);
|
|
watch(
|
|
() => props.user?.picture,
|
|
() => (failed.value = false)
|
|
);
|
|
</script>
|