Tusky icon indicating copy to clipboard operation
Tusky copied to clipboard

Error with polls from Mastodon

Open meaz opened this issue 2 years ago • 2 comments

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: Soapbox

From Tusky: Tusky


  • Tusky Version: 19

  • [x] I searched or browsed the repo’s other issues to ensure this is not a duplicate.

meaz avatar Jul 25 '22 19:07 meaz

This may be related to an issue I reported on fedi to @[email protected] - screenshot attached. Screenshot_20220803-153422_Tusky

Also in 19.

jfinkhaeuser avatar Aug 03 '22 16:08 jfinkhaeuser

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.

jfinkhaeuser avatar Aug 04 '22 07:08 jfinkhaeuser