28
28
</v-btn >
29
29
</template >
30
30
31
- <v-list >
31
+ <v-list v-if = " isAuthenticated " >
32
32
<v-list-item @click =" deleteComment(comment._id)" >
33
33
<v-list-item-title
34
34
><v-icon >mdi-trash</v-icon >Delete</v-list-item-title
55
55
<v-list-item three-line class =" pl-0" >
56
56
<v-list-item-avatar
57
57
v-if =" typeof comment.userId !== 'undefined'"
58
- class =" mt-0 "
58
+ class =" mt-2 "
59
59
size =" 40"
60
- ><v-img
61
- :src =" `${url}/uploads/avatars/${comment.userId.photoUrl}`"
60
+ >
61
+ <v-avatar v-if =" !isAuthenticated" color =" primary" >
62
+ <v-icon class =" white--text" >mdi-account</v-icon >
63
+ </v-avatar >
64
+ <v-img
65
+ v-else
66
+ :src =" `${url}/uploads/avatars/${currentUser.photoUrl}`"
62
67
></v-img
63
68
></v-list-item-avatar >
64
69
<v-list-item-content class =" align-self-auto mt-0 pt-0" >
67
72
:ref =" `${'input' + comment._id}`"
68
73
class =" pt-0 mt-0 body-2"
69
74
placeholder =" Add a public comment..."
75
+ @click =" clickTextField"
70
76
:value =" repliesInput[`input${comment._id}`]"
71
77
>
72
78
</v-text-field >
73
79
</v-form >
74
80
<div
75
81
:ref =" comment._id + 'btns'"
76
82
class =" d-inline-block text-right"
83
+ v-if =" isAuthenticated"
77
84
>
78
85
<v-btn text @click =" hideReply(comment._id)" small
79
86
>Cancel</v-btn
131
138
{{ dateFormatter(reply.createdAt) }}</span
132
139
>
133
140
</v-list-item-title >
134
- <v-menu bottom left >
141
+ <v-menu bottom left v-if = " isAuthenticated " >
135
142
<template v-slot :activator =" { on } " >
136
143
<v-btn icon v-on =" on" >
137
144
<v-icon >mdi-dots-vertical</v-icon >
175
182
176
183
<script >
177
184
import moment from ' moment'
185
+ import { mapGetters } from ' vuex'
186
+
178
187
import CommentService from ' @/services/CommentService'
179
188
import ReplyService from ' @/services/ReplyService'
180
189
export default {
@@ -195,6 +204,9 @@ export default {
195
204
loading: false
196
205
}
197
206
},
207
+ computed: {
208
+ ... mapGetters ([' isAuthenticated' , ' currentUser' ])
209
+ },
198
210
methods: {
199
211
async getComments () {
200
212
this .loading = true
@@ -210,6 +222,7 @@ export default {
210
222
// console.log(this.$store.getters.getComments.data)
211
223
},
212
224
async deleteComment (id ) {
225
+ if (! this .isAuthenticated ) return
213
226
// this.$store.dispatch('deleteComment', id)
214
227
this .comments = this .comments .filter (
215
228
(comment ) => comment ._id .toString () !== id .toString ()
@@ -227,6 +240,7 @@ export default {
227
240
this .$emit (' videoCommentLength' )
228
241
},
229
242
async addReply (event , id ) {
243
+ if (! this .isAuthenticated ) return
230
244
if (this .$refs [` input${ id} ` ][0 ].$refs .input .value == ' ' ) return
231
245
232
246
this .btnLoading = true
@@ -273,6 +287,9 @@ export default {
273
287
// .find((comment) => comment._id === id)
274
288
// .replies.unshift(reply.data.data)
275
289
},
290
+ clickTextField () {
291
+ if (! this .isAuthenticated ) return this .$router .push (' /signin' )
292
+ },
276
293
showReply (id ) {
277
294
this .$refs [id][0 ].classList .toggle (' d-none' )
278
295
},
0 commit comments