1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-21 14:19:41 +02:00
mealie/frontend/components/Domain/User/UserAvatar.vue

86 lines
1.7 KiB
Vue
Raw Normal View History

<template>
2024-10-11 19:36:26 -05:00
<v-tooltip
v-if="userId"
:disabled="!user || !tooltip"
right
>
<template #activator="{ props }">
<v-avatar
v-if="list"
v-bind="props"
>
<v-img
:src="imageURL"
:alt="userId"
@load="error = false"
@error="error = true"
/>
</v-avatar>
<v-avatar
v-else
:size="size"
v-bind="props"
>
<v-img
:src="imageURL"
:alt="userId"
@load="error = false"
@error="error = true"
/>
2024-10-11 19:36:26 -05:00
</v-avatar>
</template>
<span v-if="user">
{{ user.fullName }}
</span>
</v-tooltip>
</template>
<script lang="ts">
2024-10-11 19:36:26 -05:00
import { useUserStore } from "~/composables/store/use-user-store";
export default defineNuxtComponent({
props: {
userId: {
type: String,
required: true,
},
list: {
type: Boolean,
default: false,
},
size: {
type: String,
default: "42",
},
2024-10-11 19:36:26 -05:00
tooltip: {
type: Boolean,
default: true,
},
},
setup(props) {
const state = reactive({
error: false,
});
const $auth = useMealieAuth();
2024-10-11 19:36:26 -05:00
const { store: users } = useUserStore();
const user = computed(() => {
return users.value.find(user => user.id === props.userId);
});
const imageURL = computed(() => {
// Note: $auth.user is a ref now
const authUser = $auth.user.value;
2024-10-11 19:36:26 -05:00
const key = authUser?.cacheKey ?? "";
return `/api/media/users/${props.userId}/profile.webp?cacheKey=${key}`;
});
return {
2024-10-11 19:36:26 -05:00
user,
imageURL,
...toRefs(state),
};
},
});
Use composition API for more components, enable more type checking (#914) * Activate more linting rules from eslint and typescript * Properly add VForm as type information * Fix usage of native types * Fix more linting issues * Rename vuetify types file, add VTooltip * Fix some more typing problems * Use composition API for more components * Convert RecipeRating * Convert RecipeNutrition * Convert more components to composition API * Fix globals plugin for type checking * Add missing icon types * Fix vuetify types in Nuxt context * Use composition API for RecipeActionMenu * Convert error.vue to composition API * Convert RecipeContextMenu to composition API * Use more composition API and type checking in recipe/create * Convert AppButtonUpload to composition API * Fix some type checking in RecipeContextMenu * Remove unused components BaseAutoForm and BaseColorPicker * Convert RecipeCategoryTagDialog to composition API * Convert RecipeCardSection to composition API * Convert RecipeCategoryTagSelector to composition API * Properly import vuetify type definitions * Convert BaseButton to composition API * Convert AutoForm to composition API * Remove unused requests API file * Remove static routes from recipe API * Fix more type errors * Convert AppHeader to composition API, fixing some search bar focus problems * Convert RecipeDialogSearch to composition API * Update API types from pydantic models, handle undefined values * Improve more typing problems * Add types to other plugins * Properly type the CRUD API access * Fix typing of static image routes * Fix more typing stuff * Fix some more typing problems * Turn off more rules
2022-01-09 07:15:23 +01:00
</script>