From a9efdabcec9e83aa8586ad05f58565008c8f9839 Mon Sep 17 00:00:00 2001
From: Louis Lam <louislam@users.noreply.github.com>
Date: Sat, 12 Mar 2022 15:30:02 +0800
Subject: [PATCH] [Favicon] Prevent error when no heartbeat

---
 src/pages/StatusPage.vue | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue
index 6c529bf6..bcde1d3d 100644
--- a/src/pages/StatusPage.vue
+++ b/src/pages/StatusPage.vue
@@ -310,7 +310,7 @@ export default {
         },
 
         tagsVisible() {
-            return this.config.statusPageTags
+            return this.config.statusPageTags;
         },
 
         logoClass() {
@@ -452,7 +452,11 @@ export default {
                         const monitorHeartbeats = heartbeatList[currentId];
                         const lastHeartbeat = monitorHeartbeats.at(-1);
 
-                        return lastHeartbeat.status === 0 ? downMonitorsAmount + 1 : downMonitorsAmount;
+                        if (lastHeartbeat) {
+                            return lastHeartbeat.status === 0 ? downMonitorsAmount + 1 : downMonitorsAmount;
+                        } else {
+                            return downMonitorsAmount;
+                        }
                     }, 0);
 
                     favicon.badge(downMonitors);
@@ -519,9 +523,9 @@ export default {
                         return {
                             ...monitor,
                             tags: newState ? this.$root.monitorList[monitor.id].tags : []
-                        }
+                        };
                     })
-                }
+                };
             });
         },