St-pages - Updating a Dynamic Sidebar Menu

First post here so forgive me if I botch this…

I’m using st-pages (love it!) and many of my pages make calls to select data. When I make a selection, no matter the page, I change the corresponding st.session_state variable and my widgets all update immediately, including those in the sidebar.

The problem I am having… even though all the “widgets” update, my st-pages “dynamic” menu does not.

To build/display that menu I’ve defined a menu( ) function as:

# menu( ) - Build and display the dynamic page menu in the sidebar
# --------------------------------------------------------------------------------------
def menu(top_of_page=True):
    pages = [ Page("", "Home", "🏠"), 
                Page("", "Login to", "💪"),
                Section(name="Load Waypoints", icon=":pushpin:"),
                    Page("", "From a GPX File", ":open_file_folder:"),
                    Page("", "Query", ":question:" ),
                Section(name="Visualize Data", icon=":bar_chart:"),    
                    Page("", "Map Waypoints", ":world_map:") ] 
    if not state('loaded'):
        hide_pages( ["Visualize Data", "Map Waypoints"] )
    if not state('connected'):
        hide_pages( ["Query"] )

    if top_of_page:
        add_page_title( )   # necessary for proper menu indentation


My state( ) function is just shorthand to return an st.session_state variable. I call menu( ) at the top of every page, and tried callingmenu(False) at the bottom of every page, but that didn’t help with my problem.

I suspect I’m missing something simple here, or maybe my design isn’t what it should be. Anyone have a suggestion?

For now, I’m going to comment out the hide_pages( ) calls and add some logic in each page to determine if conditions are right to run the page or not. That way my menu won’t need to be “dynamic” at all, and it won’t keep collapsing and failing to expand when needed.

This makes me wonder if st_pages has, or might one day have, the ability to “disable” a page such that if/when it is clicked it gets grayed out, maybe with a simple popup explaining that the page is currently disabled?