@@ -29,25 +29,13 @@ import LinkSvg from '@mdi/svg/svg/link.svg?raw'
2929import CircleSvg from '../../../../core/img/apps/circles.svg?raw'
3030
3131import { action as sidebarAction } from '../../../files/src/actions/sidebarAction'
32- import { generateUrl } from '@nextcloud/router'
3332import { getCurrentUser } from '@nextcloud/auth'
33+ import { generateAvatarSvg } from '../utils/AccountIcon.ts'
3434
3535import './sharingStatusAction.scss'
3636
37- const isDarkMode = window ?. matchMedia ?.( '(prefers-color-scheme: dark)' ) ?. matches === true
38- || document . querySelector ( '[data-themes*=dark]' ) !== null
39-
40- const generateAvatarSvg = ( userId : string , isGuest = false ) => {
41- const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32'
42- const avatarUrl = generateUrl ( isGuest ? url : url + '?guestFallback=true' , { userId } )
43- return `<svg width="32" height="32" viewBox="0 0 32 32"
44- xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
45- <image href="${ avatarUrl } " height="32" width="32" />
46- </svg>`
47- }
48-
4937const isExternal = ( node : Node ) => {
50- return node . attributes . remote_id !== undefined
38+ return node . attributes ?. [ 'is-federated' ] ?? false
5139}
5240
5341export const action = new FileAction ( {
@@ -110,7 +98,8 @@ export const action = new FileAction({
11098
11199 const ownerId = node ?. attributes ?. [ 'owner-id' ]
112100 if ( ownerId && ( ownerId !== getCurrentUser ( ) ?. uid || isExternal ( node ) ) ) {
113- return generateAvatarSvg ( ownerId , isExternal ( node ) )
101+ const sanitizeId = ( id : string ) => id . replace ( / [ ^ a - z A - Z 0 - 9 . _ % + - @ ] + / g, '' ) . replace ( / \/ / g, '' )
102+ return generateAvatarSvg ( sanitizeId ( ownerId ) , isExternal ( node ) )
114103 }
115104
116105 return AccountPlusSvg
0 commit comments