bluenevus commited on
Commit
638aa65
·
1 Parent(s): 0095565

Update app.py via AI Editor

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -198,7 +198,7 @@ app.layout = dbc.Container(
198
  Input({'type': 'delete-upload-btn', 'index': ALL}, 'n_clicks'),
199
  Input('split-btn', 'n_clicks'),
200
  State('session-store', 'data'),
201
- prevent_initial_call='initial_duplicate'
202
  )
203
  def handle_upload(contents, filename, clear_n, delete_upload_n_list, split_n, session_data):
204
  trigger = ctx.triggered_id
@@ -217,7 +217,15 @@ def handle_upload(contents, filename, clear_n, delete_upload_n_list, split_n, se
217
  return "", "", resp_data
218
 
219
  # Handle Delete Upload (detect ANY delete button press)
 
220
  if isinstance(trigger, dict) and trigger.get('type') == 'delete-upload-btn':
 
 
 
 
 
 
 
221
  orig_filename = session_data.get('orig_filename', '')
222
  pdf_path = os.path.join(session_dir, orig_filename)
223
  if os.path.exists(pdf_path):
 
198
  Input({'type': 'delete-upload-btn', 'index': ALL}, 'n_clicks'),
199
  Input('split-btn', 'n_clicks'),
200
  State('session-store', 'data'),
201
+ prevent_initial_call=True
202
  )
203
  def handle_upload(contents, filename, clear_n, delete_upload_n_list, split_n, session_data):
204
  trigger = ctx.triggered_id
 
217
  return "", "", resp_data
218
 
219
  # Handle Delete Upload (detect ANY delete button press)
220
+ delete_pressed = False
221
  if isinstance(trigger, dict) and trigger.get('type') == 'delete-upload-btn':
222
+ delete_pressed = True
223
+ # Also handle if delete_upload_n_list is not None and has a value >0
224
+ if not delete_pressed and delete_upload_n_list is not None and len(delete_upload_n_list) > 0:
225
+ if any(n is not None and n > 0 for n in delete_upload_n_list):
226
+ delete_pressed = True
227
+
228
+ if delete_pressed:
229
  orig_filename = session_data.get('orig_filename', '')
230
  pdf_path = os.path.join(session_dir, orig_filename)
231
  if os.path.exists(pdf_path):