From ee94cc6bf66e290b93f4cdd1839786f044d71573 Mon Sep 17 00:00:00 2001 From: toadlyBroodle Date: Fri, 7 Apr 2023 08:41:34 +0900 Subject: [PATCH] don't allow poll authors to vote in their own polls --- .../com/vitorpamplona/amethyst/ui/note/PollNote.kt | 12 +++++++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt index d4206c482..e46645a34 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PollNote.kt @@ -71,7 +71,7 @@ fun PollNote( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 3.dp) ) { - if (zappedNote.author == account.userProfile() || zappedNote.isZappedBy(account.userProfile()) == true) { + if (zappedNote.author == account.userProfile() || zappedNote.isZappedBy(account.userProfile())) { ZapVote( baseNote, accountViewModel, @@ -209,6 +209,16 @@ fun ZapVote( ) .show() } + } else if (zappedNote?.author == account.userProfile()) { + scope.launch { + Toast + .makeText( + context, + context.getString(R.string.poll_author_no_vote), + Toast.LENGTH_SHORT + ) + .show() + } } else if (pollViewModel.isVoteAmountAtomic() && pollViewModel.isPollOptionZappedBy(pollOption, accountViewModel.userProfile())) { // only allow one vote per option when min==max, i.e. atomic vote amount specified scope.launch { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6e8947047..60375a15a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -290,4 +290,5 @@ Thank you for all your work! Create and Add + Poll authors can\'t vote in their own polls.