File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 6464 </div >
6565 </div >
6666
67- <div v-if =" isTweetOwner" class =" column is-narrow is-12-mobile" >
67+ <div v-if =" isTweetOwner(tweet.id, user.id) " class =" column is-narrow is-12-mobile" >
6868 <div class =" buttons" >
6969 <b-button type =" is-warning" @click =" onEditTweet" >Edit</b-button >
7070 <b-button type =" is-danger" @click =" onDeleteTweet" >Delete</b-button >
@@ -136,7 +136,8 @@ export default {
136136 }),
137137
138138 ... mapGetters (' tweet' , [
139- ' getTweetById'
139+ ' getTweetById' ,
140+ ' isTweetOwner'
140141 ]),
141142
142143 ... mapGetters (' comment' , [
@@ -147,10 +148,6 @@ export default {
147148 tweet () {
148149 return this .getTweetById (this .$route .params .id );
149150 },
150-
151- isTweetOwner () {
152- return this .user .id === this .tweet .author .id ;
153- },
154151 },
155152
156153 methods: {
Original file line number Diff line number Diff line change @@ -6,5 +6,8 @@ export default {
66 moment ( a . created ) . isBefore ( moment ( b . created ) ) ? 1 : - 1
77 )
88 ) ,
9- getTweetById : state => id => state . tweets [ id ]
9+
10+ getTweetById : state => id => state . tweets [ id ] ,
11+
12+ isTweetOwner : ( state , getters ) => ( tweetId , userId ) => getters . getTweetById ( tweetId ) . author . id === userId ,
1013} ;
You can’t perform that action at this time.
0 commit comments