@@ -184,6 +184,21 @@ function PopupApp() {
184184 }
185185 }
186186
187+ async function handleDeleteAsset ( assetId : string ) {
188+ if ( ! confirm ( 'Are you sure you want to delete this screenshot?' ) ) {
189+ return ;
190+ }
191+ try {
192+ await indexedDBService . deleteAsset ( assetId ) ;
193+ const updatedAssets = await indexedDBService . getAllAssets ( ) ;
194+ setAssets ( updatedAssets ) ;
195+ setEditingAsset ( null ) ;
196+ } catch ( error ) {
197+ console . error ( 'Failed to delete asset:' , error ) ;
198+ alert ( 'Failed to delete screenshot' ) ;
199+ }
200+ }
201+
187202 function openOptions ( ) {
188203 chrome . runtime . openOptionsPage ( ) ;
189204 }
@@ -323,6 +338,7 @@ function PopupApp() {
323338 asset = { editingAsset }
324339 onSave = { handleUpdateAssetMetadata }
325340 onUpload = { handleUpload }
341+ onDelete = { handleDeleteAsset }
326342 onClose = { ( ) => setEditingAsset ( null ) }
327343 />
328344 ) }
@@ -782,11 +798,13 @@ function AssetEditModal({
782798 asset,
783799 onSave,
784800 onUpload,
801+ onDelete,
785802 onClose,
786803} : {
787804 asset : Asset ;
788805 onSave : ( assetId : string , headline : string , caption : string ) => Promise < void > ;
789806 onUpload : ( assetId : string ) => void ;
807+ onDelete : ( assetId : string ) => void ;
790808 onClose : ( ) => void ;
791809} ) {
792810 const [ headline , setHeadline ] = useState ( asset . metadata ?. headline || '' ) ;
@@ -880,6 +898,22 @@ function AssetEditModal({
880898 </ button >
881899 </ div >
882900
901+ < div className = "edit-modal-delete" >
902+ < button
903+ className = "btn-delete"
904+ onClick = { ( ) => onDelete ( asset . id ) }
905+ disabled = { isSaving }
906+ >
907+ < svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" >
908+ < polyline points = "3 6 5 6 21 6" > </ polyline >
909+ < 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" > </ path >
910+ < line x1 = "10" y1 = "11" x2 = "10" y2 = "17" > </ line >
911+ < line x1 = "14" y1 = "11" x2 = "14" y2 = "17" > </ line >
912+ </ svg >
913+ Delete Screenshot
914+ </ button >
915+ </ div >
916+
883917 { asset . status === 'failed' && asset . metadata ?. error && (
884918 < div className = "edit-modal-error" >
885919 < svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" >
0 commit comments