From 5d1eb9e3b1f66eb56055881f3774db31bd696c6f Mon Sep 17 00:00:00 2001
From: Athanasius <Athanasius@miggy.org>
Date: Sat, 24 Dec 2022 10:11:11 +0000
Subject: [PATCH 1/2] Fix "could be None" conditional for call to
 `plug.notify_journal_entry()`

In testing the *first* hit on this does have `monitor.cmdr` set, but neither
`monitor.system` or `monitor.station`.  So:

1. Allow those to be `None` in the function signature,
2. Guard against only `monitor.cmdr` being falsey before the call.
3. Move the `if err:` to the same scope.
---
 EDMarketConnector.py | 10 +++++-----
 plug.py              |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/EDMarketConnector.py b/EDMarketConnector.py
index b9c7bdf2..d6af828f 100755
--- a/EDMarketConnector.py
+++ b/EDMarketConnector.py
@@ -1457,7 +1457,7 @@ class AppWindow(object):
                     and config.get_int('output') & config.OUT_SHIP:
                 monitor.export_ship()
 
-            if monitor.cmdr and monitor.system and monitor.station:
+            if monitor.cmdr:
                 err = plug.notify_journal_entry(
                     monitor.cmdr,
                     monitor.is_beta,
@@ -1467,10 +1467,10 @@ class AppWindow(object):
                     monitor.state
                 )
 
-            if err:
-                self.status['text'] = err
-                if not config.get_int('hotkey_mute'):
-                    hotkeymgr.play_bad()
+                if err:
+                    self.status['text'] = err
+                    if not config.get_int('hotkey_mute'):
+                        hotkeymgr.play_bad()
 
             auto_update = False
             # Only if auth callback is not pending
diff --git a/plug.py b/plug.py
index 8e19a6cf..e0c69a44 100644
--- a/plug.py
+++ b/plug.py
@@ -286,7 +286,7 @@ def notify_prefs_changed(cmdr: str | None, is_beta: bool) -> None:
 
 
 def notify_journal_entry(
-    cmdr: str, is_beta: bool, system: str, station: str,
+    cmdr: str, is_beta: bool, system: str | None, station: str | None,
     entry: MutableMapping[str, Any],
     state: Mapping[str, Any]
 ) -> Optional[str]:

From 81a8122c5971e922e951e10e3bd5780b034589d2 Mon Sep 17 00:00:00 2001
From: Athanasius <Athanasius@miggy.org>
Date: Sat, 24 Dec 2022 10:15:41 +0000
Subject: [PATCH 2/2] Indent `if err:` check after plugin dashboard invocation

Adding a mypy-make-happy conditional on the call above means `err` needs
to be inside that as well.
---
 EDMarketConnector.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/EDMarketConnector.py b/EDMarketConnector.py
index d6af828f..5edae5a3 100755
--- a/EDMarketConnector.py
+++ b/EDMarketConnector.py
@@ -1550,10 +1550,10 @@ class AppWindow(object):
         if monitor.cmdr:
             err = plug.notify_dashboard_entry(monitor.cmdr, monitor.is_beta, entry)
 
-        if err:
-            self.status['text'] = err
-            if not config.get_int('hotkey_mute'):
-                hotkeymgr.play_bad()
+            if err:
+                self.status['text'] = err
+                if not config.get_int('hotkey_mute'):
+                    hotkeymgr.play_bad()
 
     def plugin_error(self, event=None) -> None:
         """Display asynchronous error from plugin."""