1
1
import { ChangeEvent , useRef , useState } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
- import { isNonEmptyArray } from '@sniptt/guards' ;
4
3
import { IconPlus } from 'twenty-ui' ;
5
4
5
+ import { SkeletonLoader } from '@/activities/components/SkeletonLoader' ;
6
6
import { AttachmentList } from '@/activities/files/components/AttachmentList' ;
7
7
import { DropZone } from '@/activities/files/components/DropZone' ;
8
8
import { useAttachments } from '@/activities/files/hooks/useAttachments' ;
@@ -15,6 +15,7 @@ import {
15
15
AnimatedPlaceholderEmptySubTitle ,
16
16
AnimatedPlaceholderEmptyTextContainer ,
17
17
AnimatedPlaceholderEmptyTitle ,
18
+ EMPTY_PLACEHOLDER_TRANSITION_PROPS ,
18
19
} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled' ;
19
20
import { isDefined } from '~/utils/isDefined' ;
20
21
@@ -41,7 +42,7 @@ export const Attachments = ({
41
42
targetableObject : ActivityTargetableObject ;
42
43
} ) => {
43
44
const inputFileRef = useRef < HTMLInputElement > ( null ) ;
44
- const { attachments } = useAttachments ( targetableObject ) ;
45
+ const { attachments, loading } = useAttachments ( targetableObject ) ;
45
46
const { uploadAttachmentFile } = useUploadAttachmentFile ( ) ;
46
47
47
48
const [ isDraggingFile , setIsDraggingFile ] = useState ( false ) ;
@@ -58,7 +59,13 @@ export const Attachments = ({
58
59
await uploadAttachmentFile ( file , targetableObject ) ;
59
60
} ;
60
61
61
- if ( ! isNonEmptyArray ( attachments ) ) {
62
+ const isAttachmentsEmpty = ! attachments || attachments . length === 0 ;
63
+
64
+ if ( loading && isAttachmentsEmpty ) {
65
+ return < SkeletonLoader /> ;
66
+ }
67
+
68
+ if ( isAttachmentsEmpty ) {
62
69
return (
63
70
< StyledDropZoneContainer onDragEnter = { ( ) => setIsDraggingFile ( true ) } >
64
71
{ isDraggingFile ? (
@@ -67,7 +74,10 @@ export const Attachments = ({
67
74
onUploadFile = { onUploadFile }
68
75
/>
69
76
) : (
70
- < AnimatedPlaceholderEmptyContainer >
77
+ < AnimatedPlaceholderEmptyContainer
78
+ // eslint-disable-next-line react/jsx-props-no-spreading
79
+ { ...EMPTY_PLACEHOLDER_TRANSITION_PROPS }
80
+ >
71
81
< AnimatedPlaceholder type = "noFile" />
72
82
< AnimatedPlaceholderEmptyTextContainer >
73
83
< AnimatedPlaceholderEmptyTitle >
0 commit comments