CCockrum commited on
Commit
b5432ab
·
verified ·
1 Parent(s): e9e17cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -225,8 +225,9 @@ def display_pet_card(pet, is_favorite=False):
225
  col1, col2 = st.columns(2)
226
  with col1:
227
  if st.button("View Details", key=f"details_{pet['id']}"):
 
228
  st.session_state.selected_pet = pet['id']
229
- st.experimental_rerun() # <-- replace st.stop() with this
230
 
231
  with col2:
232
  if not is_favorite:
@@ -293,8 +294,9 @@ def display_pet_details(pet_id):
293
 
294
  # Back button
295
  if st.button("← Back to Search Results"):
 
296
  st.session_state.selected_pet = None
297
- st.experimental_rerun() # <-- replace st.stop() with this
298
 
299
  # Pet name and status
300
  st.markdown(f"<h1 class='main-header'>{pet['name']}</h1>", unsafe_allow_html=True)
 
225
  col1, col2 = st.columns(2)
226
  with col1:
227
  if st.button("View Details", key=f"details_{pet['id']}"):
228
+ if st.session_state.selected_pet != pet['id']:
229
  st.session_state.selected_pet = pet['id']
230
+ st.experimental_rerun() # Force immediate rerun
231
 
232
  with col2:
233
  if not is_favorite:
 
294
 
295
  # Back button
296
  if st.button("← Back to Search Results"):
297
+ if st.session_state.selected_pet is not None:
298
  st.session_state.selected_pet = None
299
+ st.experimental_rerun() # Force immediate rerun
300
 
301
  # Pet name and status
302
  st.markdown(f"<h1 class='main-header'>{pet['name']}</h1>", unsafe_allow_html=True)