@@ -43,7 +43,7 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
4343 const fetchDocumentHistory = async ( ) => {
4444 setLoading ( true ) ;
4545 setError ( null ) ;
46-
46+
4747 try {
4848 const response = await getDocumentHistory ( resource , collectionName , documentId ) ;
4949 setHistoryData ( response ) ;
@@ -130,11 +130,15 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
130130
131131 const renderDiffData = ( entry : DocumentHistoryEntry ) => {
132132 if ( entry . operation === 'insert' ) {
133+ const insertData = { ...( entry . diff_data as Record < string , any > ) } ;
134+ delete insertData [ 'datetime_creation' ] ;
135+ delete insertData [ 'datetime_last_modified' ] ;
136+
133137 return (
134138 < div className = "mt-2 p-3 bg-green-100 dark:bg-green-900/30 rounded border" >
135139 < p className = "text-sm font-medium text-green-800 dark:text-green-200 mb-2" > Document created with initial data:</ p >
136140 < div className = "text-xs font-mono bg-white dark:bg-gray-800 p-2 rounded border max-h-48 overflow-y-auto" >
137- < pre className = "whitespace-pre-wrap break-words overflow-wrap-anywhere" > { JSON . stringify ( entry . diff_data , null , 2 ) } </ pre >
141+ < pre className = "whitespace-pre-wrap break-words overflow-wrap-anywhere" > { JSON . stringify ( insertData , null , 2 ) } </ pre >
138142 </ div >
139143 </ div >
140144 ) ;
@@ -149,8 +153,12 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
149153 }
150154
151155 // Update operation
152- const changes = Object . entries ( entry . diff_data as Record < string , any > ) ;
153-
156+ const diffData = { ...( entry . diff_data as Record < string , any > ) } ;
157+ delete diffData [ 'datetime_creation' ] ;
158+ delete diffData [ 'datetime_last_modified' ] ;
159+
160+ const changes = Object . entries ( diffData ) ;
161+
154162 return (
155163 < div className = "mt-2 space-y-2" >
156164 { changes . map ( ( [ field , change ] , index ) => (
@@ -238,7 +246,10 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
238246 { historyData . history_entries . map ( ( entry : DocumentHistoryEntry ) => {
239247 const timestamp = formatTimestamp ( entry . timestamp_utc ) ;
240248 const isExpanded = expandedEntries . has ( entry . id ) ;
241- const hasChanges = entry . operation === 'update' && Object . keys ( entry . diff_data ) . length > 0 ;
249+ const diffDataKeys = Object . keys ( entry . diff_data || { } ) . filter ( k =>
250+ ! [ 'datetime_creation' , 'datetime_last_modified' ] . includes ( k )
251+ ) ;
252+ const hasChanges = entry . operation === 'update' && diffDataKeys . length > 0 ;
242253
243254 return (
244255 < div
@@ -250,7 +261,7 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
250261 < div className = "flex-shrink-0 mt-0.5" >
251262 { getOperationIcon ( entry . operation ) }
252263 </ div >
253-
264+
254265 < div className = "flex-1 min-w-0" >
255266 < div className = "flex items-center gap-2 mb-1" >
256267 < span className = "font-medium text-gray-900 dark:text-gray-100 capitalize" >
@@ -262,7 +273,7 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
262273 < span > { entry . user_email } </ span >
263274 </ div >
264275 </ div >
265-
276+
266277 < div className = "flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400 mb-2" >
267278 < AccessTimeIcon className = "w-3 h-3" />
268279 < span > { timestamp . relative } </ span >
@@ -276,7 +287,7 @@ const DocumentHistoryDialog: React.FC<DocumentHistoryDialogProps> = ({
276287 className = "inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-200 transition-colors"
277288 >
278289 { isExpanded ? < ChevronDownIcon className = "w-3 h-3" /> : < ChevronRightIcon className = "w-3 h-3" /> }
279- { Object . keys ( entry . diff_data ) . length } field{ Object . keys ( entry . diff_data ) . length !== 1 ? 's' : '' } changed
290+ { diffDataKeys . length } field{ diffDataKeys . length !== 1 ? 's' : '' } changed
280291 </ button >
281292 ) }
282293
0 commit comments