Skip to content

Commit

Permalink
Merge remote-tracking branch 'mentalisit/master' into fork/master
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/CompendiumPage.vue
  • Loading branch information
userXinos committed May 16, 2024
2 parents 840e8ea + 2dd87cb commit d2b7b17
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/pages/CompendiumCorp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="meta">
<div class="avatar">
<img
:src="getDiscordAvatarUrl(mem.userId, mem.avatar)"
:src="getAvatarUrl(mem.avatarUrl)"
:alt="`${mem.name} avatar`"
@error="(e) => e.target.src = memberImage"
></div>
Expand Down Expand Up @@ -143,7 +143,7 @@ import { onMounted, reactive, Ref, ref, watch } from 'vue';
import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';
import { getDiscordAvatarUrl } from '@Utils/getDiscordUrl';
import { getAvatarUrl } from '@Utils/getDiscordUrl';
import client from '../utils/compendium';
import types from '@/store/modules/userSettings/types';
Expand Down
33 changes: 28 additions & 5 deletions src/utils/getDiscordUrl.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
const ENDPOINT = 'https://cdn.discordapp.com/';
// const ENDPOINT = 'https://cdn.discordapp.com/';


export function getDiscordAvatarUrl(userId: string, avatarHash: string, size = 80): URL {
const url = new URL(`avatars/${userId}/${avatarHash}.webp`, ENDPOINT);
// export function getDiscordAvatarUrl(userId: string, avatarHash: string, size = 80): URL {
// const url = new URL(`avatars/${userId}/${avatarHash}.webp`, ENDPOINT);
//
// url.searchParams.set('size', String(size));
// return url;
// }

export function getAvatarUrl(userAvatarUrl: string, size = 80): URL {
if (userAvatarUrl === '') {
userAvatarUrl = 'https://github.com/userXinos/HadesSpace/blob/master/src/img/icons/member.png';
}
userAvatarUrl = userAvatarUrl.replace(/\.png/g, '.webp');
const url = new URL(`${userAvatarUrl}`);

url.searchParams.set('size', String(size));
return url;
}
export function getDiscordIconUrl(guildId: string, iconHash: string, size = 96): URL {
const url = new URL(`icons/${guildId}/${iconHash}.webp`, ENDPOINT);

// export function getDiscordIconUrl(guildId: string, iconHash: string, size = 96): URL {
// const url = new URL(`icons/${guildId}/${iconHash}.webp`, ENDPOINT);
//
// url.searchParams.set('size', String(size));
// return url;
// }

export function getIconUrl(urlGuild: string, size = 96): URL {
if (urlGuild === '') {
urlGuild = 'https://github.com/userXinos/HadesSpace/blob/master/src/img/icons/member.png';
}
urlGuild = urlGuild.replace(/\.png/g, '.webp');
const url = new URL(`${urlGuild}`);

url.searchParams.set('size', String(size));
return url;
Expand Down

0 comments on commit d2b7b17

Please sign in to comment.