Skip to content

Commit

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

Added storedCredentials check to ImagePost
  • Loading branch information
Sebastian-Webster authored Sep 20, 2023
2 parents ff02891 + ac77507 commit 6f1a9c2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions components/Posts/ImagePost.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ class ImagePost 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()
const url = this.props.serverUrl + '/tempRoute/upvoteimage';
Expand Down Expand Up @@ -92,9 +102,9 @@ class ImagePost extends Component {
console.error(error)
})
}
}
})

downvote = () => {
downvote = this.runIfAuthenticated(() => {
if (!this.props.post.changingVote) {
this.handleStartVoteChange()
const url = this.props.serverUrl + '/tempRoute/downvoteimage';
Expand Down Expand Up @@ -124,7 +134,7 @@ class ImagePost extends Component {
console.error(error)
})
}
}
})

navigateToFullscreen = () => {
this.props.navigation.navigate("ViewImagePostPage", {
Expand All @@ -133,7 +143,7 @@ class ImagePost extends Component {
})
}

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 @@ -147,7 +157,7 @@ class ImagePost extends Component {
postIndex: this.props.index,
onDeleteCallback: this.props.onDeleteCallback
})
}
})

render() {
return (
Expand Down

0 comments on commit 6f1a9c2

Please sign in to comment.