Tusky
Tusky copied to clipboard
Error with polls from Mastodon
I'm using Tusky with a pleroma instance. When there is survey on mastodon, and I participate, it always seems that I'm the only one that participate. However, if I check the same survey from Soapbox, I don't have this problem. Here are two screenshots so that it may makes more sense.
From Soapbox:
From Tusky:
-
Tusky Version: 19
-
[x] I searched or browsed the repo’s other issues to ensure this is not a duplicate.
This may be related to an issue I reported on fedi to @[email protected] - screenshot attached.
Also in 19.
Honestly, https://github.com/tuskyapp/Tusky/blob/d07c1b098ed0b5c2d9e49512146da4bfb5590b1f/app/src/main/java/com/keylesspalace/tusky/viewdata/PollViewData.kt#L46 looks good-ish. I'm not 100% sure what Kotlin's roundToInt()
actually does, but https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/round-to-int.html suggests it rounds to the nearest int, so offhand that looks good.
There's a different issue that I can see in that the code in https://github.com/tuskyapp/Tusky/blob/a2cc622683073862f8842ceb9ed764d32ccf2a47/app/src/main/java/com/keylesspalace/tusky/adapter/PollAdapter.kt#L88 relies on the vote/voter count in the Poll data from the API being reported correctly. It's possible that the issue isn't Tusky, but Mastodon here.
As a defensive move, it'd probably be better for Tusky to sum up the number of votes of all PollOptionViewData
manually, and use that sum to calculate the percentage. That should also be a sane choice whether or not voters_count
or votes_count
is provided (see https://github.com/tuskyapp/Tusky/blob/d07c1b098ed0b5c2d9e49512146da4bfb5590b1f/app/src/main/java/com/keylesspalace/tusky/entity/Poll.kt#L12 ), as well as when polls are multiple choice.
TL;DR, I suspect the source a bit.