Parcourir la source

Fixed issues with WhatisNew modal spamming console errors.

KrisVos130 il y a 8 ans
Parent
commit
51d9f7627c
1 fichiers modifiés avec 9 ajouts et 7 suppressions
  1. 9 7
      frontend/components/Modals/WhatIsNew.vue

+ 9 - 7
frontend/components/Modals/WhatIsNew.vue

@@ -1,5 +1,5 @@
 <template>
-	<div class='modal' :class='{ "is-active": isModalActive }'>
+	<div class='modal' :class='{ "is-active": isModalActive }' v-if="news !== null">
 		<div class='modal-background'></div>
 		<div class='modal-card'>
 			<header class='modal-card-head'>
@@ -44,7 +44,7 @@
 		data() {
 			return {
 				isModalActive: false,
-				news: {}
+				news: null
 			}
 		},
 		ready: function () {
@@ -54,14 +54,16 @@
 					_this.socket = _this.$parent.socket;
 					_this.socket.emit('news.newest', res => {
 						_this.news = res.data;
-						if (localStorage.getItem('whatIsNew')) {
-							if (parseInt(localStorage.getItem('whatIsNew')) < res.data.createdAt) {
+						if (_this.news) {
+							if (localStorage.getItem('whatIsNew')) {
+								if (parseInt(localStorage.getItem('whatIsNew')) < res.data.createdAt) {
+									this.toggleModal();
+									localStorage.setItem('whatIsNew', res.data.createdAt);
+								}
+							} else {
 								this.toggleModal();
 								localStorage.setItem('whatIsNew', res.data.createdAt);
 							}
-						} else {
-							this.toggleModal();
-							localStorage.setItem('whatIsNew', res.data.createdAt);
 						}
 					});
 					clearInterval(socketInterval);