Skip to content

Commit

Permalink
add username param
Browse files Browse the repository at this point in the history
  • Loading branch information
claromes committed Jun 25, 2024
1 parent 4aabc2a commit bd63c88
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
)

# ------ Set States ------ #
# ------ Set States and Params ------ #

if "current_username" not in st.session_state:
st.session_state.current_username = ""
Expand All @@ -56,6 +56,15 @@
if "archived_timestamp_filter" not in st.session_state:
st.session_state.archived_timestamp_filter = (start_date, end_date)

if "username_param" not in st.session_state:
st.session_state.username_param = ""

if "expanded_param" not in st.session_state:
st.session_state.expanded_param = False

if "username" not in st.query_params:
st.query_params["username"] = ""

# ------ Add Custom CSS Style ------ #

st.html(
Expand Down Expand Up @@ -126,6 +135,15 @@ def tweets_exporter(parsed_tweets, username, field_options):
return df, file_name


# ------Query Params ------ #

if st.query_params.username != "":
st.session_state.username_param = st.query_params.username
st.session_state.expanded_param = True

if st.query_params.username == "":
st.query_params.clear()

# ------ User Interface Settings ------ #

st.info(
Expand All @@ -152,9 +170,14 @@ def tweets_exporter(parsed_tweets, username, field_options):

# -- Filters -- #

username = st.text_input("Username *", key="username", placeholder="Without @")
username = st.text_input(
"Username *",
value=st.session_state.username_param,
key="username",
placeholder="Without @",
)

with st.expander("Filtering"):
with st.expander("Filtering", expanded=st.session_state.expanded_param):

st.session_state.archived_timestamp_filter = st.date_input(
"Tweets saved between",
Expand Down

0 comments on commit bd63c88

Please sign in to comment.