mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-05-24 01:12:54 -04:00
* add vitest * initialize lib w/ tests * move to dev dep * run tests in CI * update file names * move api folder to lib * move api and api types to same folder * update generator outpath * rm husky * i guess i _did_ need those types * reorg types * extract validators into testable components * (WIP) start composable testing * fix import type * fix linter complaint * simplify icon type def * fix linter errors (maybe?) * rename client file for sorting
50 lines
1.2 KiB
Vue
50 lines
1.2 KiB
Vue
<template>
|
|
<v-list-item-avatar v-if="list && userId">
|
|
<v-img :src="imageURL" :alt="userId" @load="error = false" @error="error = true"> </v-img>
|
|
</v-list-item-avatar>
|
|
<v-avatar v-else-if="userId" :size="size">
|
|
<v-img :src="imageURL" :alt="userId" @load="error = false" @error="error = true"> </v-img>
|
|
</v-avatar>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, toRefs, reactive, useContext, computed } from "@nuxtjs/composition-api";
|
|
import { UserOut } from "~/lib/api/types/user";
|
|
|
|
export default defineComponent({
|
|
props: {
|
|
userId: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
list: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
size: {
|
|
type: String,
|
|
default: "42",
|
|
},
|
|
},
|
|
setup(props) {
|
|
const state = reactive({
|
|
error: false,
|
|
});
|
|
|
|
const { $auth } = useContext();
|
|
|
|
const imageURL = computed(() => {
|
|
// TODO Setup correct user type for $auth.user
|
|
const user = $auth.user as unknown as UserOut | null;
|
|
const key = user?.cacheKey ?? "";
|
|
return `/api/media/users/${props.userId}/profile.webp?cacheKey=${key}`;
|
|
});
|
|
|
|
return {
|
|
imageURL,
|
|
...toRefs(state),
|
|
};
|
|
},
|
|
});
|
|
</script>
|