BasitAliii commited on
Commit
7383f67
·
verified ·
1 Parent(s): be4f650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -32,7 +32,6 @@ def init_session_state():
32
  "wants_text_input": "",
33
  "availability_input": "",
34
  "preferences_input": "",
35
- "avatar_file_input": None,
36
  "feedback_input": "",
37
  }
38
  for k, v in defaults.items():
@@ -62,7 +61,7 @@ tabs = st.tabs(["Community", "AI Matchmaking", "About"])
62
  with tabs[0]:
63
  st.header("👥 Community Profiles")
64
 
65
- # Sidebar form for profile management
66
  with st.expander("📝 Create / Update Profile", expanded=True):
67
  profiles = store.load_all()
68
  usernames = [p.username for p in profiles]
@@ -107,8 +106,7 @@ with tabs[0]:
107
  )
108
  avatar_file = st.file_uploader(
109
  "Upload Avatar (Max 800MB)",
110
- type=["png", "jpg", "jpeg"],
111
- key="avatar_file_input"
112
  )
113
 
114
  # Avatar preview
@@ -116,7 +114,7 @@ with tabs[0]:
116
  st.image(avatar_file, width=150, caption="Preview of avatar")
117
  if avatar_file.size > 800 * 1024 * 1024:
118
  st.error("File exceeds maximum size of 800MB!")
119
- st.session_state["avatar_file_input"] = None
120
 
121
  # Buttons
122
  col1, col2, col3 = st.columns([1, 1, 1])
@@ -152,9 +150,11 @@ with tabs[0]:
152
  if ok:
153
  st.success(msg)
154
  # Clear inputs after creation
155
- for key in ["username_input", "offers_text_input", "wants_text_input",
156
- "availability_input", "preferences_input", "avatar_file_input"]:
157
- st.session_state[key] = "" if "file" not in key else None
 
 
158
  st.experimental_rerun()
159
  else:
160
  st.error(msg)
@@ -188,9 +188,11 @@ with tabs[0]:
188
  if st.button("🗑️ Delete Profile", use_container_width=True):
189
  store.delete(selected_user)
190
  st.warning("Profile deleted")
191
- for key in ["username_input", "offers_text_input", "wants_text_input",
192
- "availability_input", "preferences_input", "avatar_file_input"]:
193
- st.session_state[key] = "" if "file" not in key else None
 
 
194
  st.experimental_rerun()
195
 
196
  # Display community profiles
 
32
  "wants_text_input": "",
33
  "availability_input": "",
34
  "preferences_input": "",
 
35
  "feedback_input": "",
36
  }
37
  for k, v in defaults.items():
 
61
  with tabs[0]:
62
  st.header("👥 Community Profiles")
63
 
64
+ # Sidebar-like form inside tab
65
  with st.expander("📝 Create / Update Profile", expanded=True):
66
  profiles = store.load_all()
67
  usernames = [p.username for p in profiles]
 
106
  )
107
  avatar_file = st.file_uploader(
108
  "Upload Avatar (Max 800MB)",
109
+ type=["png", "jpg", "jpeg"]
 
110
  )
111
 
112
  # Avatar preview
 
114
  st.image(avatar_file, width=150, caption="Preview of avatar")
115
  if avatar_file.size > 800 * 1024 * 1024:
116
  st.error("File exceeds maximum size of 800MB!")
117
+ avatar_file = None
118
 
119
  # Buttons
120
  col1, col2, col3 = st.columns([1, 1, 1])
 
150
  if ok:
151
  st.success(msg)
152
  # Clear inputs after creation
153
+ st.session_state["username_input"] = ""
154
+ st.session_state["offers_text_input"] = ""
155
+ st.session_state["wants_text_input"] = ""
156
+ st.session_state["availability_input"] = ""
157
+ st.session_state["preferences_input"] = ""
158
  st.experimental_rerun()
159
  else:
160
  st.error(msg)
 
188
  if st.button("🗑️ Delete Profile", use_container_width=True):
189
  store.delete(selected_user)
190
  st.warning("Profile deleted")
191
+ st.session_state["username_input"] = ""
192
+ st.session_state["offers_text_input"] = ""
193
+ st.session_state["wants_text_input"] = ""
194
+ st.session_state["availability_input"] = ""
195
+ st.session_state["preferences_input"] = ""
196
  st.experimental_rerun()
197
 
198
  # Display community profiles