Skip to content

Commit 5993ed4

Browse files
refactor(connection_toaster): extract duplicated dev mode check to variable for readability
1 parent 2d14f28 commit 5993ed4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

reflex/components/core/banner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ def add_hooks(self) -> list[str | Var]:
102102
toast_id = "websocket-error"
103103
target_url = WebsocketTargetURL.create()
104104
config = get_config()
105+
is_dev_mode = environment.REFLEX_ENV_MODE.get().value == constants.Env.DEV
105106
props = ToastProps(
106107
description=LiteralVar.create(
107108
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
109+
if is_dev_mode or not config.connection_error_message
110110
else config.connection_error_message
111111
),
112112
close_button=True,
@@ -140,8 +140,7 @@ def add_hooks(self) -> list[str | Var]:
140140
else:
141141
loading_message = Var.create(
142142
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
143+
if is_dev_mode or not config.connection_error_message
145144
else ""
146145
)
147146
toast_var = Var(

0 commit comments

Comments
 (0)