npc0 commited on
Commit
3371ce8
·
verified ·
1 Parent(s): 5d9ad4f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +11 -7
src/streamlit_app.py CHANGED
@@ -999,6 +999,7 @@ def view_topic_page():
999
  # Update the user's progress to the next comment they should see.
1000
  update_user_progress(user_id, topic_id, next_comment_id)
1001
 
 
1002
  st.rerun() # Rerun to update UI
1003
 
1004
  except Exception as e:
@@ -1007,23 +1008,26 @@ def view_topic_page():
1007
  if local_con:
1008
  local_con.close()
1009
 
1010
- st.session_state._voting_in_progress = False
1011
  col1, col2, col3, col4 = st.columns(4)
1012
  user_id = find_or_create_user(user_email) # Ensure user exists
1013
 
1014
  col1.markdown("*Personally I...*")
1015
  if col2.button("Agree", disabled=st.session_state.get('_voting_in_progress', False)):
1016
  # Set a flag immediately to disable buttons until next render
1017
- st.session_state._voting_in_progress = True
1018
- handle_vote("agree", current_comment_id, topic_id, user_id)
 
1019
  if col3.button("Neutral", disabled=st.session_state.get('_voting_in_progress', False)):
1020
  # Set a flag immediately to disable buttons until next render
1021
- st.session_state._voting_in_progress = True
1022
- handle_vote("neutral", current_comment_id, topic_id, user_id)
 
1023
  if col4.button("Disagree", disabled=st.session_state.get('_voting_in_progress', False)):
1024
  # Set a flag immediately to disable buttons until next render
1025
- st.session_state._voting_in_progress = True
1026
- handle_vote("disagree", current_comment_id, topic_id, user_id)
 
1027
 
1028
  else:
1029
  st.info("No more comments to vote on in this topic." if "No more comments" in current_comment_content else current_comment_content)
 
999
  # Update the user's progress to the next comment they should see.
1000
  update_user_progress(user_id, topic_id, next_comment_id)
1001
 
1002
+ st.session_state._voting_in_progress = False
1003
  st.rerun() # Rerun to update UI
1004
 
1005
  except Exception as e:
 
1008
  if local_con:
1009
  local_con.close()
1010
 
1011
+ st.session_state._voting_in_progress = st.session_state.get("_voting_in_progress", False)
1012
  col1, col2, col3, col4 = st.columns(4)
1013
  user_id = find_or_create_user(user_email) # Ensure user exists
1014
 
1015
  col1.markdown("*Personally I...*")
1016
  if col2.button("Agree", disabled=st.session_state.get('_voting_in_progress', False)):
1017
  # Set a flag immediately to disable buttons until next render
1018
+ if st.session_state._voting_in_progress == False:
1019
+ st.session_state._voting_in_progress = True
1020
+ handle_vote("agree", current_comment_id, topic_id, user_id)
1021
  if col3.button("Neutral", disabled=st.session_state.get('_voting_in_progress', False)):
1022
  # Set a flag immediately to disable buttons until next render
1023
+ if st.session_state._voting_in_progress == False:
1024
+ st.session_state._voting_in_progress = True
1025
+ handle_vote("neutral", current_comment_id, topic_id, user_id)
1026
  if col4.button("Disagree", disabled=st.session_state.get('_voting_in_progress', False)):
1027
  # Set a flag immediately to disable buttons until next render
1028
+ if st.session_state._voting_in_progress == False:
1029
+ st.session_state._voting_in_progress = True
1030
+ handle_vote("disagree", current_comment_id, topic_id, user_id)
1031
 
1032
  else:
1033
  st.info("No more comments to vote on in this topic." if "No more comments" in current_comment_content else current_comment_content)