@@ -870,6 +870,41 @@ const UploadHistorySection: React.FC<UploadHistoryProps> = ({ address, setShowUp
870870 }
871871 } ;
872872
873+ const clearExpiredHistory = ( ) => {
874+ if ( ! address ) return ;
875+
876+ const now = Date . now ( ) ;
877+ const expiredCount = history . filter ( record => record . expiryDate < now ) . length ;
878+
879+ if ( expiredCount === 0 ) {
880+ window . alert ( 'No expired items to clear.' ) ;
881+ return ;
882+ }
883+
884+ const confirmed = window . confirm (
885+ `Are you sure you want to clear ${ expiredCount } expired item${ expiredCount > 1 ? 's' : '' } from your upload history? This action cannot be undone.`
886+ ) ;
887+ if ( confirmed ) {
888+ // Filter out expired items
889+ const nonExpiredHistory = history . filter ( record => record . expiryDate >= now ) ;
890+ setHistory ( nonExpiredHistory ) ;
891+
892+ // Update localStorage
893+ const savedHistory = localStorage . getItem ( 'uploadHistory' ) ;
894+ if ( savedHistory ) {
895+ const allHistory : UploadHistory = JSON . parse ( savedHistory ) ;
896+ allHistory [ address ] = nonExpiredHistory ;
897+ localStorage . setItem ( 'uploadHistory' , JSON . stringify ( allHistory ) ) ;
898+ }
899+ }
900+ } ;
901+
902+ // Count expired items for button visibility
903+ const expiredCount = React . useMemo ( ( ) => {
904+ const now = Date . now ( ) ;
905+ return history . filter ( record => record . expiryDate < now ) . length ;
906+ } , [ history ] ) ;
907+
873908 const startEditingFilename = (
874909 index : number ,
875910 reference : string ,
@@ -1008,8 +1043,12 @@ const UploadHistorySection: React.FC<UploadHistoryProps> = ({ address, setShowUp
10081043 </ svg >
10091044 </ label >
10101045 ) }
1011- { history . length > 0 && (
1012- < button className = { styles . clearButton } onClick = { clearHistory } title = "Clear History" >
1046+ { expiredCount > 0 && (
1047+ < button
1048+ className = { styles . clearExpiredButton }
1049+ onClick = { clearExpiredHistory }
1050+ title = { `Clear ${ expiredCount } Expired Item${ expiredCount > 1 ? 's' : '' } ` }
1051+ >
10131052 < svg
10141053 width = "20"
10151054 height = "20"
@@ -1020,15 +1059,15 @@ const UploadHistorySection: React.FC<UploadHistoryProps> = ({ address, setShowUp
10201059 strokeLinecap = "round"
10211060 strokeLinejoin = "round"
10221061 >
1023- < polyline points = "3,6 5,6 21,6 " />
1024- < path d = "m19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2 " />
1025- < line x1 = "10" y1 = "11" x2 = "10" y2 = "17 " />
1026- < line x1 = "14" y1 = "11" x2 = "14" y2 = "17 " />
1062+ < path d = "M5 22h14 " />
1063+ < path d = "M5 2h14 " />
1064+ < path d = "M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22 " />
1065+ < path d = "M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2 " />
10271066 </ svg >
10281067 </ button >
10291068 ) }
1030- { address && (
1031- < div className = { styles . ensInfo } >
1069+ { history . length > 0 && (
1070+ < button className = { styles . clearButton } onClick = { clearHistory } title = "Clear History" >
10321071 < svg
10331072 width = "20"
10341073 height = "20"
@@ -1039,13 +1078,12 @@ const UploadHistorySection: React.FC<UploadHistoryProps> = ({ address, setShowUp
10391078 strokeLinecap = "round"
10401079 strokeLinejoin = "round"
10411080 >
1042- < circle cx = "12" cy = "12" r = "10" />
1043- < path d = "M12 2L2 7v10c0 5.55 3.84 10 9 10s9-4.45 9-10V7L12 2z" />
1081+ < polyline points = "3,6 5,6 21,6" />
1082+ < path d = "m19,6v14a2,2 0 0,1 -2,2H7a2,2 0 0,1 -2,-2V6m3,0V4a2,2 0 0,1 2,-2h4a2,2 0 0,1 2,2v2" />
1083+ < line x1 = "10" y1 = "11" x2 = "10" y2 = "17" />
1084+ < line x1 = "14" y1 = "11" x2 = "14" y2 = "17" />
10441085 </ svg >
1045- < span className = { styles . ensTooltip } >
1046- Click on ENS button to link reference to your ENS domain
1047- </ span >
1048- </ div >
1086+ </ button >
10491087 ) }
10501088 </ div >
10511089 </ div >
@@ -1131,6 +1169,27 @@ const UploadHistorySection: React.FC<UploadHistoryProps> = ({ address, setShowUp
11311169 </ div >
11321170 ) }
11331171
1172+ { /* ENS Note */ }
1173+ { address && history . length > 0 && (
1174+ < div className = { styles . ensNote } >
1175+ < svg
1176+ width = "16"
1177+ height = "16"
1178+ viewBox = "0 0 24 24"
1179+ fill = "none"
1180+ stroke = "currentColor"
1181+ strokeWidth = "2"
1182+ strokeLinecap = "round"
1183+ strokeLinejoin = "round"
1184+ >
1185+ < circle cx = "12" cy = "12" r = "10" />
1186+ < line x1 = "12" y1 = "16" x2 = "12" y2 = "12" />
1187+ < line x1 = "12" y1 = "8" x2 = "12.01" y2 = "8" />
1188+ </ svg >
1189+ < span > Click on ENS button to link reference to your ENS domain</ span >
1190+ </ div >
1191+ ) }
1192+
11341193 { ! address ? (
11351194 < div className = { styles . emptyState } > Connect wallet to check upload history</ div >
11361195 ) : history . length === 0 ? (
0 commit comments