From f3e7841b1bf971e53cd9b978eccc070113b9faa7 Mon Sep 17 00:00:00 2001
From: Simone Margaritelli <evilsocket@gmail.com>
Date: Sat, 12 Oct 2019 17:53:18 +0200
Subject: [PATCH] misc: small fix or general refactoring i did not bother
 commenting

---
 pwnagotchi/plugins/default/grid.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pwnagotchi/plugins/default/grid.py b/pwnagotchi/plugins/default/grid.py
index a1ecd22..516a6a2 100644
--- a/pwnagotchi/plugins/default/grid.py
+++ b/pwnagotchi/plugins/default/grid.py
@@ -159,7 +159,9 @@ def on_internet_available(agent):
         TOTAL_MESSAGES = len(messages)
         UNREAD_MESSAGES = len([m for m in messages if m['seen_at'] is None])
 
-        logging.debug( " %d unread messages of %d total" % (UNREAD_MESSAGES, TOTAL_MESSAGES))
+        if TOTAL_MESSAGES:
+            on_ui_update(agent.view())
+            logging.debug( " %d unread messages of %d total" % (UNREAD_MESSAGES, TOTAL_MESSAGES))
 
         logging.debug("checking pcaps")