refactor: move getDisplayAvatar into profile composable
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful

This commit is contained in:
Twig 2025-08-11 22:25:16 +02:00
parent 8dbab14c2e
commit 10bf54b6fd
Signed by: twig
SSH key fingerprint: SHA256:nBO+OwpTkd8LYhe38PIqdxmDvkIg9Vw2EbrRZM97dkU
3 changed files with 33 additions and 26 deletions

View file

@ -6,7 +6,7 @@
<DefaultIcon v-else
class="display-avatar"
:name="displayName"
:seed="user.uuid"
:seed="getUserUuid(props.profile)"
:alt="displayName" />
</template>
@ -14,25 +14,14 @@
import { NuxtImg } from '#components';
import type { GuildMemberResponse, UserResponse } from '~/types/interfaces';
const { getDisplayName } = useProfile()
const { getDisplayName, getAvatarUrl, getUserUuid } = useProfile()
const props = defineProps<{
profile: UserResponse | GuildMemberResponse,
}>();
const displayName = getDisplayName(props.profile)
let user: UserResponse
let displayAvatar: string | null
if ("username" in props.profile) {
// assume it's a UserResponse
displayAvatar = props.profile.avatar
user = props.profile
} else {
// assume it's a GuildMemberResponse
displayAvatar = props.profile.user.avatar
user = props.profile.user
}
const displayAvatar = getAvatarUrl(props.profile)
</script>

View file

@ -62,7 +62,7 @@ import type { GuildMemberResponse, ModalProps, UserResponse } from '~/types/inte
import VerticalSpacer from '../UserInterface/VerticalSpacer.vue';
import Button from '../UserInterface/Button.vue';
const { getDisplayName, getUsername, getPronouns, getAboutMe, getRegistrationDate, getGuildJoinDate, getFriendsSince, getUuid } = useProfile()
const { getDisplayName, getUsername, getPronouns, getAboutMe, getRegistrationDate, getGuildJoinDate, getFriendsSince, getUserUuid } = useProfile()
const { addFriend, fetchMe } = useApi();
const props = defineProps<ModalProps & {
@ -81,7 +81,7 @@ const registrationDate = getRegistrationDate(props.profile)
const joinDate = getGuildJoinDate(props.profile)
const friendsSince = await getFriendsSince(props.profile)
const uuid = getUuid(props.profile)
const uuid = getUserUuid(props.profile)
function toDateString(date: Date): string {