Prechádzať zdrojové kódy

warn if notification can not be displayed

Rodja Trappe 1 rok pred
rodič
commit
80676808ed
1 zmenil súbory, kde vykonal 4 pridanie a 1 odobranie
  1. 4 1
      nicegui/functions/notify.py

+ 4 - 1
nicegui/functions/notify.py

@@ -49,4 +49,7 @@ def notify(message: Any, *,
     options = {ARG_MAP.get(key, key): value for key, value in locals().items() if key != 'kwargs' and value is not None}
     options = {ARG_MAP.get(key, key): value for key, value in locals().items() if key != 'kwargs' and value is not None}
     options['message'] = str(message)
     options['message'] = str(message)
     options.update(kwargs)
     options.update(kwargs)
-    outbox.enqueue_message('notify', options, globals.get_client().id)
+    if not globals.get_client().has_socket_connection:
+        globals.log.warning(f'notification "{message}" was ignored because the client is not connected')
+    else:
+        outbox.enqueue_message('notify', options, globals.get_client().id)