Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "show results" for polls #4980

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Add "show results" for polls #4980

wants to merge 2 commits into from

Conversation

Tak
Copy link
Collaborator

@Tak Tak commented Mar 7, 2025

Body of a post with the 'Show Results' button

setVoted(tuskyAccountId, statusId, moshi.adapter<Poll>().toJson(poll.copy(voted = true)))
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this, but it feels better than adding another field and updating the "which poll view should I show" logic 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this you mean setting the poll to voted when it isn't actually voted? I think that is fine.

But you could include the poll or the whole status in the PollShowResultsEvent then you don't need the getStatus here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this I mean the function doing query/deserialize/update
It's not trivial to include more stuff in the PollShowResultsEvent - the other events are created from a network call that includes those in the response from the server
I could pass the whole status into the StatusActionListener callback I guess, but even then I'm not sure I always have it

Copy link
Collaborator

@connyduck connyduck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

setVoted(tuskyAccountId, statusId, moshi.adapter<Poll>().toJson(poll.copy(voted = true)))
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this you mean setting the poll to voted when it isn't actually voted? I think that is fine.

But you could include the poll or the whole status in the PollShowResultsEvent then you don't need the getStatus here.

@@ -183,6 +183,16 @@ WHERE tuskyAccountId = :tuskyAccountId AND serverId = :statusId"""
)
abstract suspend fun setVoted(tuskyAccountId: Long, statusId: String, poll: String)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found out that one can do this:

Suggested change
abstract suspend fun setVoted(tuskyAccountId: Long, statusId: String, poll: String)
@TypeConverters(Converters::class)
abstract suspend fun setVoted(tuskyAccountId: Long, statusId: String, poll: Poll)

and then there is no more need for the manual json conversion with Moshi

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants