From b6c7c414021e03a95b4f13d82d9d692cabd3bd1e Mon Sep 17 00:00:00 2001
From: Audric Ackermann <audric@loki.network>
Date: Thu, 10 Sep 2020 09:06:05 +1000
Subject: [PATCH] fix read-receipt being sent onFocus on invalid conversation

---
 app/tray_icon.js              | 3 ++-
 js/views/conversation_view.js | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/app/tray_icon.js b/app/tray_icon.js
index 88a32ac93..7dfdf1fd2 100644
--- a/app/tray_icon.js
+++ b/app/tray_icon.js
@@ -65,7 +65,8 @@ function createTrayIcon(getMainWindow, messages) {
     trayContextMenu = Menu.buildFromTemplate([
       {
         id: 'toggleWindowVisibility',
-        label: messages[mainWindow.isVisible() ? 'appMenuHide' : 'show'].message,
+        label:
+          messages[mainWindow.isVisible() ? 'appMenuHide' : 'show'].message,
         click: tray.toggleWindowVisibility,
       },
       {
diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js
index 097556d16..3f3cb13c4 100644
--- a/js/views/conversation_view.js
+++ b/js/views/conversation_view.js
@@ -391,7 +391,10 @@
       this.window.addEventListener('resize', this.onResize);
 
       this.onFocus = () => {
-        if (this.$el.css('display') !== 'none') {
+        if (
+          this.$el.css('display') !== 'none' &&
+          this.$el.css('display') !== ''
+        ) {
           this.markRead();
         }
       };