File tree Expand file tree Collapse file tree 2 files changed +26
-24
lines changed
Expand file tree Collapse file tree 2 files changed +26
-24
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,13 @@ const Description = ({ form, attachmentsDisabled }) => {
8888
8989 const { data : serverInfo } = ologApi . endpoints . getServerInfo . useQuery ( ) ;
9090
91+ const generateUniqueFileName = ( file ) => {
92+ return new File ( [ file ] , `${ new Date ( ) . getTime ( ) } -${ file . name } ` , {
93+ type : file . type ,
94+ lastModified : file . lastModified
95+ } ) ;
96+ } ;
97+
9198 /**
9299 * Appends an attachment object to the attachments form field
93100 * @param {* } event
@@ -96,7 +103,12 @@ const Description = ({ form, attachmentsDisabled }) => {
96103 if ( files ) {
97104 // note event.target.files is a FileList, not an array! But we can convert it
98105 Array . from ( files ) . forEach ( ( file ) => {
99- appendAttachment ( new OlogAttachment ( { file, id : uuidv4 ( ) } ) ) ;
106+ appendAttachment (
107+ new OlogAttachment ( {
108+ file : generateUniqueFileName ( file ) ,
109+ id : uuidv4 ( )
110+ } )
111+ ) ;
100112 } ) ;
101113 }
102114 } ;
@@ -123,16 +135,7 @@ const Description = ({ form, attachmentsDisabled }) => {
123135 let imageFile = null ;
124136 for ( let item of items ) {
125137 if ( item . kind === "file" && item . type . match ( / ^ i m a g e / ) ) {
126- imageFile = item . getAsFile ( ) ;
127-
128- imageFile = new File (
129- [ imageFile ] ,
130- `${ new Date ( ) . getTime ( ) } -${ imageFile . name } ` ,
131- {
132- type : imageFile . type ,
133- lastModified : imageFile . lastModified
134- }
135- ) ;
138+ imageFile = generateUniqueFileName ( item . getAsFile ( ) ) ;
136139 }
137140 }
138141 if ( imageFile ) {
Original file line number Diff line number Diff line change @@ -37,21 +37,20 @@ const MetadataTable = ({ log }) => (
3737 ) ) }
3838 </ Key >
3939
40- < Key name = "Tags" >
41- { log ?. tags ?. map ( ( it ) => (
42- < TagChip
43- sx = { { fontSize : ".7rem" } }
44- key = { it . name }
45- value = { it . name }
46- />
47- ) ) }
48- </ Key >
40+ { log ?. tags . length > 0 && (
41+ < Key name = "Tags" >
42+ { log ?. tags ?. map ( ( it ) => (
43+ < TagChip
44+ key = { it . name }
45+ sx = { { fontSize : ".7rem" } }
46+ value = { it . name }
47+ />
48+ ) ) }
49+ </ Key >
50+ ) }
4951
5052 { log ?. level && (
51- < Key
52- name = "Entry type"
53- value
54- >
53+ < Key name = "Entry type" >
5554 < EntryTypeChip
5655 sx = { { fontSize : ".7rem" } }
5756 key = { log ?. level }
You can’t perform that action at this time.
0 commit comments