|
16 | 16 | from reflex.components.radix.themes.layout.flex import Flex |
17 | 17 | from reflex.components.radix.themes.typography.text import Text |
18 | 18 | from reflex.components.sonner.toast import ToastProps, toast_ref |
| 19 | +from reflex.config import get_config |
19 | 20 | from reflex.constants import Dirs, Hooks, Imports |
20 | 21 | from reflex.constants.compiler import CompileVars |
21 | 22 | from reflex.environment import environment |
@@ -100,9 +101,13 @@ def add_hooks(self) -> list[str | Var]: |
100 | 101 | """ |
101 | 102 | toast_id = "websocket-error" |
102 | 103 | target_url = WebsocketTargetURL.create() |
| 104 | + config = get_config() |
103 | 105 | props = ToastProps( |
104 | 106 | description=LiteralVar.create( |
105 | | - f"Check if server is reachable at {target_url}", |
| 107 | + f"Check if server is reachable at {target_url}" |
| 108 | + if environment.REFLEX_ENV_MODE.get().value == constants.Env.DEV |
| 109 | + or not config.connection_error_message |
| 110 | + else config.connection_error_message |
106 | 111 | ), |
107 | 112 | close_button=True, |
108 | 113 | duration=120000, |
@@ -135,6 +140,9 @@ def add_hooks(self) -> list[str | Var]: |
135 | 140 | else: |
136 | 141 | loading_message = Var.create( |
137 | 142 | f"Cannot connect to server: {connection_error}." |
| 143 | + if environment.REFLEX_ENV_MODE.get().value == constants.Env.DEV |
| 144 | + or not config.connection_error_message |
| 145 | + else "" |
138 | 146 | ) |
139 | 147 | toast_var = Var( |
140 | 148 | f"toast?.error({loading_message!s}, {{...toast_props, onDismiss: () => setUserDismissed(true)}},)" |
|
0 commit comments