Преглед на файлове

warn if notification can not be displayed

Rodja Trappe преди 1 година
родител
ревизия
80676808ed
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  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['message'] = str(message)
     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)