Skip to content

Commit

Permalink
fix: error session_state has no attribute 'page'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiogra committed Jul 14, 2023
1 parent 78dd18a commit de58ad9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
datefmt="%Y-%m-%d %H:%M:%S",
)

DEFAULT_PAGE = "Separate"


def header(logo_and_title=True):
if "first_run" not in st.session_state:
Expand All @@ -31,7 +33,7 @@ def header(logo_and_title=True):
if "search_results" not in st.session_state:
st.session_state.search_results = []
if "page" not in st.session_state:
switch_page("Separate")
switch_page(DEFAULT_PAGE)

st.set_page_config(
page_title="Moseca - Music Separation and Karaoke - Free and Open Source alternative to lalal.ai, splitter.ai or media.io vocal remover.",
Expand All @@ -42,17 +44,18 @@ def header(logo_and_title=True):
st.markdown(CSS, unsafe_allow_html=True)

options = ["Separate", "Karaoke", "About"]

page = option_menu(
menu_title=None,
options=options,
# bootrap icons
icons=["play-btn-fill", "file-earmark-music", "info-circle"],
default_index=options.index(st.session_state.page),
default_index=options.index(st.session_state.get("page", DEFAULT_PAGE)),
orientation="horizontal",
styles={"nav-link": {"padding-left": "1.5rem", "padding-right": "1.5rem"}},
key="",
)
if page != st.session_state.page:
if page != st.session_state.get("page", DEFAULT_PAGE):
switch_page(page)

if logo_and_title:
Expand Down

0 comments on commit de58ad9

Please sign in to comment.