From f04ea8fa00e8e94b428707397811fec8e2114696 Mon Sep 17 00:00:00 2001 From: Fabien Lelaquais Date: Fri, 2 Aug 2024 08:53:02 +0200 Subject: [PATCH] Better initialization --- doc/gui/examples/controls/chat-discuss.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/gui/examples/controls/chat-discuss.py b/doc/gui/examples/controls/chat-discuss.py index eb0cad1782..a295df08ea 100644 --- a/doc/gui/examples/controls/chat-discuss.py +++ b/doc/gui/examples/controls/chat-discuss.py @@ -36,6 +36,12 @@ def send(state, _: str, payload: dict): state.messages = messages +def on_init(state): + # Copy the global variables users and messages to this user's state + state.users = users + state.messages = messages + + def on_navigate(state, path: str): # Navigate to the 'register' page if the user is not registered if path == "discuss" and state.username == "": @@ -61,8 +67,6 @@ def register(state): register_page = """ -<|toggle|theme|> - Please enter your user name: <|{username}|input|> @@ -71,8 +75,6 @@ def register(state): """ discuss_page = """ -<|toggle|theme|> - <|### Let's discuss, {username}|text|mode=markdown|> <|{messages}|chat|users={users}|sender_id={username}|on_action=send|>