Skip to content

Commit

Permalink
Merge pull request #199 from SquareTable/191-add-storedcredentials-ch…
Browse files Browse the repository at this point in the history
…eck-to-threadpost-when-voting

Added storedCredentials check to ThreadPost
  • Loading branch information
Sebastian-Webster authored Sep 20, 2023
2 parents 6f1a9c2 + 4c7d281 commit 7411a70
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions components/Posts/ThreadPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ class Thread extends Component {
})
}

upvote = () => {
runIfAuthenticated = (func) => {
return () => {
if (this.props.userId === 'SSGUEST' || !this.props.userId) {
this.props.navigation.navigate('ModalLoginScreen', {modal: true})
} else {
func()
}
}
}

upvote = this.runIfAuthenticated(() => {
if (!this.props.post.changingVote) {
this.handleStartVoteChange()

Expand Down Expand Up @@ -91,9 +101,9 @@ class Thread extends Component {
console.error('An error occured while upvoting thread post:', error)
})
}
}
})

downvote = () => {
downvote = this.runIfAuthenticated(() => {
if (!this.props.post.changingVote) {
this.handleStartVoteChange()

Expand Down Expand Up @@ -126,13 +136,13 @@ class Thread extends Component {
console.error('An error occured while downvoting thread post:', error)
})
}
}
})

navigateToFullScreen = () => {
this.props.navigation.navigate("ThreadViewPage", { threadId: this.props.post._id })
}

openThreeDotsMenu = () => {
openThreeDotsMenu = this.runIfAuthenticated(() => {
if (this.props.post.isOwner !== true && this.props.post.isOwner !== false) {
alert("isOwner is not true or false. An error has occured.")
return
Expand All @@ -145,7 +155,7 @@ class Thread extends Component {
isOwner: this.props.post.isOwner,
postIndex: this.props.index
})
}
})

render() {
return (
Expand Down

0 comments on commit 7411a70

Please sign in to comment.