Add Poll/Question support#162
Conversation
Re-introspect the server schema, which now exposes Poll.closed/viewerHasVoted, PollOption.index/viewerHasVoted, and the voteOnPoll and createQuestion mutations. Remove the local markNotificationsAsRead extension now that the server provides it natively (with an optional upTo argument).
Add a PollFields fragment and select it via ... on Question { poll } in both PostFields and SharedPostFields so poll state travels with every post query.
Add Poll and PollOption domain classes, a nullable Post.poll field, and a PollFields.toPoll() mapper wired into both PostFields.toPost and SharedPostFields.toPost.
Add a PollView composable showing each option with a proportional result bar, percentage, voted marker, total voters, choice mode, and a live open/closed status. Render it for Question posts in NoteCard and the post detail screen.
Add a VoteOnPoll operation returning the updated Question and a repository voteOnPoll(questionId, optionIndices) that maps the payload back to a Post, branching on the result union.
Let PollView select options and submit a vote, replacing its displayed state with the server response. Thread an onVotePoll callback through PostCard/NoteCard and wire it in the post detail screen and personal timeline; add voteOnPoll to PostDetailViewModel and TimelineViewModel.
Add voteOnPoll to the explore, bookmarks, search, and profile view models and pass onVotePoll into their PostCard usages so polls are votable everywhere they render, not only in the timeline and detail screens.
Add a CreateQuestion operation and a repository createQuestion(...) that builds CreateQuestionPollInput (title, options, multiple, ISO-8601 ends) and maps the payload to a Post, branching on the result union.
Add poll-draft state (title, 2-20 options, multiple-choice, duration) to ComposeViewModel with validation, and branch post() to createQuestion when a poll is attached. Add a poll toggle to the composer toolbar and a PollComposerSection for editing the poll.
Always show the remove-option button but disable it when only two options remain, and move the multiple-choice toggle to the bottom-left of the poll editor as a plain inline switch.
Give the multiple-choice toggle its own full-width row with spacing so it no longer overlaps the duration control, keep the duration dropdown, and make the media/poll/quoted section scroll vertically so poll fields stay reachable while the keyboard is open.
Fetch PollEndedNotification in the notifications query, map it to a Notification.PollEnded domain type, and render it in the notifications list and push notification text with a poll icon and "<actor>'s poll ended" copy.
Add a chevron in the poll editor header that collapses the fields to just the header (poll icon, label, chevron, remove), keeping the poll attached. Animate the size change so the compose area stays compact.
When the poll editor is collapsed, hide the inline form and show a small floating action button in the compose area to reopen it; when expanded, render the full editor as before. Lift the expanded state to ComposeScreen so the collapsed state can render the FAB overlay.
Replace the inline poll editor (and its collapse chevron/floating button) with a full-screen poll editor opened from the compose toolbar. The editor has a back/Save top bar (Save enabled only when the poll is valid) and, once saved, the note shows a compact poll summary chip that reopens the editor or removes the poll. Poll draft state stays in ComposeViewModel, so the editor swaps in without extra navigation plumbing.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (24)
📝 WalkthroughWalkthroughThe Android client adds poll creation, voting, rendering, and poll-ended notifications. GraphQL operations and schema types support poll data, while repository mappings, ViewModels, Compose screens, post cards, notifications, and localized strings carry the feature through the application. ChangesPoll support
GraphQL schema expansion
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ComposeScreen
participant ComposeViewModel
participant HackersPubRepository
participant GraphQLAPI
User->>ComposeScreen: Configure poll
ComposeScreen->>ComposeViewModel: Save poll draft
User->>ComposeScreen: Publish question
ComposeScreen->>ComposeViewModel: post()
ComposeViewModel->>HackersPubRepository: createQuestion(poll)
HackersPubRepository->>GraphQLAPI: CreateQuestion
GraphQLAPI-->>HackersPubRepository: Created question with poll
HackersPubRepository-->>ComposeViewModel: Result<Post>
ComposeViewModel-->>ComposeScreen: Published state
User->>ComposeScreen: Select poll options
ComposeScreen->>HackersPubRepository: voteOnPoll(questionId, optionIndices)
HackersPubRepository->>GraphQLAPI: VoteOnPoll
GraphQLAPI-->>HackersPubRepository: Updated question with poll
HackersPubRepository-->>ComposeScreen: Result<Poll>
Possibly related PRs
Suggested reviewers: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds full Poll/Question support to the Android app, matching the server's GraphQL poll API — rendering, voting, authoring, and poll-ended notifications.
What's included
PollFieldsfragment onPoll, and wired poll data intoPostFields/SharedPostFields.ends.voteOnPollmutation wired through every feed (timeline, explore, bookmarks, search, profile) and post detail; the poll view self-updates from the server response.createQuestion.Checks
./gradlew :app:lintDebugpasses.!!in production code.