@@ -84,7 +84,7 @@ class GistCommentsScreen extends React.Component {
84
84
this . state = {
85
85
comment : '' ,
86
86
isVisible : false ,
87
- id : null ,
87
+ commentId : null ,
88
88
} ;
89
89
}
90
90
componentDidMount ( ) {
@@ -103,10 +103,11 @@ class GistCommentsScreen extends React.Component {
103
103
this . setState ( { isVisible : false } ) ;
104
104
}
105
105
106
- openGistOptions = id => {
106
+ openGistOptions = ( commentId , userId ) => {
107
+ if ( userId !== this . props . currentUserId ) return ;
107
108
this . setState ( {
108
109
isVisible : true ,
109
- id ,
110
+ commentId ,
110
111
} ) ;
111
112
}
112
113
@@ -118,13 +119,15 @@ class GistCommentsScreen extends React.Component {
118
119
this . onCancel ( ) ;
119
120
this . props . deleteThisComment ( {
120
121
gistId : this . props . navigation . getParam ( 'gistData' ) . id ,
121
- commentId : this . state . id ,
122
+ commentId : this . state . commentId ,
122
123
} ) ;
123
124
}
124
125
125
126
renderItem = ( { item } ) => {
126
127
return (
127
- < TouchableOpacity style = { { flex : 1 } } onLongPress = { ( ) => this . openGistOptions ( item . id ) } >
128
+ < TouchableOpacity
129
+ style = { { flex : 1 } }
130
+ onLongPress = { ( ) => this . openGistOptions ( item . id , item . user . id ) } >
128
131
< CardContainer
129
132
cardElevation = { 2 }
130
133
cardMaxElevation = { 2 }
@@ -194,9 +197,9 @@ const mapDispatchToProps = dispatch => ({
194
197
deleteThisComment : data => dispatch ( deleteComment . action ( data ) ) ,
195
198
addThisComment : data => dispatch ( addComment . action ( data ) ) ,
196
199
} ) ;
197
- const mapStateToProps = ( { gistComments, auth } ) => ( {
200
+ const mapStateToProps = ( { gistComments, loggedInUser } ) => ( {
198
201
comments : gistComments . comments ,
199
- accessToken : auth . access_token ,
202
+ currentUserId : loggedInUser . userId ,
200
203
inProgress : gistComments . inProgress ,
201
204
} ) ;
202
205
0 commit comments