Skip to content

Commit

Permalink
fix(files_sharing): federated shares avatar
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Oct 25, 2024
1 parent 7723faf commit 1f9ca94
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/files_sharing/src/utils/AccountIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ const isDarkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches
|| document.querySelector('[data-themes*=dark]') !== null

export const generateAvatarSvg = (userId: string, isGuest = false) => {
const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32'
const avatarUrl = generateUrl(isGuest ? url : url + '?guestFallback=true', { userId })
// normal avatar url: /avatar/{userId}/32?guestFallback=true
// dark avatar url: /avatar/{userId}/32/dark?guestFallback=true
// guest avatar url: /avatar/guest/{userId}/32
// guest dark avatar url: /avatar/guest/{userId}/32/dark
const basePath = isGuest ? `/avatar/guest/${userId}` : `/avatar/${userId}`
const darkModePath = isDarkMode ? '/dark' : ''
const guestFallback = isGuest ? '' : '?guestFallback=true'

const url = `${basePath}/32${darkModePath}${guestFallback}`
const avatarUrl = generateUrl(url, { userId })
return `<svg width="32" height="32" viewBox="0 0 32 32"
xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
<image href="${avatarUrl}" height="32" width="32" />
Expand Down

0 comments on commit 1f9ca94

Please sign in to comment.