diff --git a/apps/files_sharing/src/actions/sharingStatusAction.ts b/apps/files_sharing/src/actions/sharingStatusAction.ts index 8dd1b40330490..75b63c588541b 100644 --- a/apps/files_sharing/src/actions/sharingStatusAction.ts +++ b/apps/files_sharing/src/actions/sharingStatusAction.ts @@ -35,7 +35,7 @@ import { generateAvatarSvg } from '../utils/AccountIcon.ts' import './sharingStatusAction.scss' const isExternal = (node: Node) => { - return node.attributes?.['is-federated'] ?? false + return node.attributes.remote_id !== undefined } export const action = new FileAction({ @@ -43,10 +43,9 @@ export const action = new FileAction({ displayName(nodes: Node[]) { const node = nodes[0] const shareTypes = Object.values(node?.attributes?.['share-types'] || {}).flat() as number[] - const ownerId = node?.attributes?.['owner-id'] if (shareTypes.length > 0 - || (ownerId !== getCurrentUser()?.uid || isExternal(node))) { + || (node.owner !== getCurrentUser()?.uid || isExternal(node))) { return t('files_sharing', 'Shared') } @@ -55,15 +54,14 @@ export const action = new FileAction({ title(nodes: Node[]) { const node = nodes[0] - const ownerId = node?.attributes?.['owner-id'] - const ownerDisplayName = node?.attributes?.['owner-display-name'] // Mixed share types if (Array.isArray(node.attributes?.['share-types']) && node.attributes?.['share-types'].length > 1) { return t('files_sharing', 'Shared multiple times with different people') } - if (ownerId && (ownerId !== getCurrentUser()?.uid || isExternal(node))) { + if (node.owner && (node.owner !== getCurrentUser()?.uid || isExternal(node))) { + const ownerDisplayName = node?.attributes?.['owner-display-name'] return t('files_sharing', 'Shared by {ownerDisplayName}', { ownerDisplayName }) } @@ -96,10 +94,9 @@ export const action = new FileAction({ return CircleSvg } - const ownerId = node?.attributes?.['owner-id'] - if (ownerId && (ownerId !== getCurrentUser()?.uid || isExternal(node))) { + if (node.owner && (node.owner !== getCurrentUser()?.uid || isExternal(node))) { const sanitizeId = (id: string) => id.replace(/[^a-zA-Z0-9._%+@-]+/g, '').replace(/\//g, '') - return generateAvatarSvg(sanitizeId(ownerId), isExternal(node)) + return generateAvatarSvg(sanitizeId(node.owner), isExternal(node)) } return AccountPlusSvg @@ -111,8 +108,8 @@ export const action = new FileAction({ } const node = nodes[0] - const ownerId = node?.attributes?.['owner-id'] - const isMixed = Array.isArray(node.attributes?.['share-types']) + const shareTypes = node.attributes?.['share-types'] + const isMixed = Array.isArray(shareTypes) && shareTypes.length > 0 // If the node is shared multiple times with // different share types to the current user @@ -121,7 +118,7 @@ export const action = new FileAction({ } // If the node is shared by someone else - if (ownerId && (ownerId !== getCurrentUser()?.uid || isExternal(node))) { + if (node.owner && (node.owner !== getCurrentUser()?.uid || isExternal(node))) { return true }