James McCool commited on
Commit
0b14eea
Β·
1 Parent(s): fdf9a85

Implement session state cleanup on pagination navigation in app.py

Browse files

- Added logic to clear 'player_frame' and 'stack_frame' from session state when navigating between pages, ensuring a fresh state for user selections.
- This enhancement improves session management and prevents potential data carryover between pagination actions.

Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -264,12 +264,18 @@ with tab2:
264
  with pagination_cols[1]:
265
  if st.button("← Previous", disabled=st.session_state.current_page == 0):
266
  st.session_state.current_page -= 1
 
 
 
 
267
  with pagination_cols[2]:
268
  st.markdown(f"**Page {st.session_state.current_page + 1} of {total_pages}**", unsafe_allow_html=True)
269
  with pagination_cols[3]:
270
  if st.button("Next β†’", disabled=st.session_state.current_page == total_pages - 1):
271
  st.session_state.current_page += 1
272
-
 
 
273
  # Calculate start and end indices for current page
274
  start_idx = st.session_state.current_page * rows_per_page
275
  end_idx = min((st.session_state.current_page + 1) * rows_per_page, total_rows)
 
264
  with pagination_cols[1]:
265
  if st.button("← Previous", disabled=st.session_state.current_page == 0):
266
  st.session_state.current_page -= 1
267
+ if 'player_frame' in st.session_state:
268
+ del st.session_state['player_frame']
269
+ del st.session_state['stack_frame']
270
+
271
  with pagination_cols[2]:
272
  st.markdown(f"**Page {st.session_state.current_page + 1} of {total_pages}**", unsafe_allow_html=True)
273
  with pagination_cols[3]:
274
  if st.button("Next β†’", disabled=st.session_state.current_page == total_pages - 1):
275
  st.session_state.current_page += 1
276
+ if 'player_frame' in st.session_state:
277
+ del st.session_state['player_frame']
278
+ del st.session_state['stack_frame']
279
  # Calculate start and end indices for current page
280
  start_idx = st.session_state.current_page * rows_per_page
281
  end_idx = min((st.session_state.current_page + 1) * rows_per_page, total_rows)