From cac0a46bace5b96681b694ad33a7938c7b6c32ff Mon Sep 17 00:00:00 2001
From: LouisLam <louislam@users.noreply.github.com>
Date: Sat, 9 Oct 2021 19:08:38 +0800
Subject: [PATCH] fix error if tls info object is in old format

---
 src/pages/Details.vue | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/pages/Details.vue b/src/pages/Details.vue
index ee0c4948..1363aa20 100644
--- a/src/pages/Details.vue
+++ b/src/pages/Details.vue
@@ -83,6 +83,7 @@
                 </div>
             </div>
 
+            <!-- Cert Info Box -->
             <transition name="slide-fade" appear>
                 <div v-if="showCertInfoBox" class="shadow-box big-padding text-center">
                     <div class="row">
@@ -93,6 +94,7 @@
                 </div>
             </transition>
 
+            <!-- Ping Chart -->
             <div v-if="showPingChartBox" class="shadow-box big-padding text-center ping-chart-wrapper">
                 <div class="row">
                     <div class="col">
@@ -270,7 +272,10 @@ export default {
         },
 
         tlsInfo() {
-            if (this.$root.tlsInfoList[this.monitor.id]) {
+            // Add: this.$root.tlsInfoList[this.monitor.id].certInfo
+            // Fix: TypeError: Cannot read properties of undefined (reading 'validTo')
+            // Reason: TLS Info object format is changed in 1.8.0, if for some reason, it cannot connect to the site after update to 1.8.0, the object is still in the old format.
+            if (this.$root.tlsInfoList[this.monitor.id] && this.$root.tlsInfoList[this.monitor.id].certInfo) {
                 return this.$root.tlsInfoList[this.monitor.id];
             }