Pārlūkot izejas kodu

Add conditional clause to check if user still exists in notification

sbkwgh 8 gadi atpakaļ
vecāks
revīzija
f538b2cfc3
1 mainītis faili ar 12 papildinājumiem un 2 dzēšanām
  1. 12 2
      src/components/NotificationButton.vue

+ 12 - 2
src/components/NotificationButton.vue

@@ -54,7 +54,12 @@
 						</div>
 						<div>
 							<span class='notification_button__menu__item__link'>
-								{{notification.PostNotification.User.username}}
+								<template v-if='notification.PostNotification.User'>
+									{{notification.PostNotification.User.username}}
+								</template>
+								<template v-else>
+									[deleted]
+								</template>
 							</span>
 							wrote
 							"{{notification.PostNotification.Post.content | stripTags | truncate(50)}}"
@@ -74,7 +79,12 @@
 						</div>
 						<div>
 							<span class='notification_button__menu__item__link'>
-								{{notification.PostNotification.User.username}}
+								<template v-if='notification.PostNotification.User'>
+									{{notification.PostNotification.User.username}}
+								</template>
+								<template v-else>
+									[deleted]
+								</template>
 							</span>
 							replied
 							"{{notification.PostNotification.Post.content | stripTags | truncate(50)}}"