-
Notifications
You must be signed in to change notification settings - Fork 296
Add NIP-88 polls support #3253
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
base: master
Are you sure you want to change the base?
Add NIP-88 polls support #3253
Conversation
note this is 100% pure vibe generated on a non-mac machine, and untested. will attempt testing now on xcode/macos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements NIP-88 polls support in Damus, adding comprehensive poll functionality including creation, voting, and results display. The implementation introduces domain models for polls, a shared store for managing poll state, and integrates polling capabilities throughout the app.
- Introduces poll domain models (PollEvent, PollResponse, PollDraft) and supporting infrastructure
- Adds a PollResultsStore for managing poll state and vote submission with relay subscriptions
- Integrates poll UI components in the composer and timeline with validation and voting functionality
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 8 comments.
Show a summary per file
File | Description |
---|---|
damusTests/PollTests.swift | Adds unit tests for poll event parsing and vote submission logic |
damusTests/Mocking/MockDamusState.swift | Updates mock state to include poll store |
damus/TestData.swift | Updates test data to include poll store |
damus/Shared/Utilities/HeadlessDamusState.swift | Adds polls property to headless state protocol |
damus/Features/Timeline/Models/HomeModel.swift | Adds poll event handling and subscription filters |
damus/Features/Posting/Views/PostView.swift | Integrates poll composer UI and validation logic |
damus/Features/Posting/Models/Post.swift | Adds poll kind handling in event creation |
damus/Features/Posting/Models/DraftsModel.swift | Adds poll draft support to draft artifacts |
damus/Features/Polls/Views/PollEventView.swift | Implements poll display and voting UI |
damus/Features/Polls/Views/PollComposerView.swift | Implements poll creation interface |
damus/Features/Polls/Models/PollVoteBuilder.swift | Handles poll response event creation |
damus/Features/Polls/Models/PollResultsStore.swift | Manages poll state and vote submission |
damus/Features/Polls/Models/PollModels.swift | Defines poll domain models and parsing logic |
damus/Features/Polls/Models/PollDraft.swift | Defines poll draft structure for composition |
damus/Features/Events/EventView.swift | Adds poll event rendering support |
damus/Core/Storage/DamusState.swift | Integrates poll store into main app state |
damus/Core/Nostr/NostrKind.swift | Adds poll and poll_response event kinds |
damus.xcodeproj/project.pbxproj | Updates project file with new poll-related source files |
DamusNotificationService/NotificationExtensionState.swift | Adds poll store to notification extension state |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
} | ||
|
||
func subscribe_to_home_filters(friends fs: [Pubkey]? = nil, relay_id: RelayURL? = nil) { | ||
// TODO: separate likes? |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider grouping poll-related kinds together or adding a comment explaining the ordering rationale for better code organization.
// TODO: separate likes? | |
// TODO: separate likes? | |
// The ordering of kinds below is intentional for timeline display. | |
// Only one poll-related kind (.poll) exists currently; if more are added, group them together. |
Copilot uses AI. Check for mistakes.
func send_post() { | ||
let new_post = build_post(state: self.damus_state, post: self.post, action: action, uploadedMedias: uploadedMedias, references: self.references, filtered_pubkeys: filtered_pubkeys) | ||
let new_post = build_post(state: self.damus_state, post: self.post, action: action, uploadedMedias: uploadedMedias, references: self.references, filtered_pubkeys: filtered_pubkeys, pollDraft: pollDraft) |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This function call has many parameters. Consider creating a struct to encapsulate these parameters for better readability and maintainability.
Copilot uses AI. Check for mistakes.
// PollEventView.swift | ||
// damus | ||
// | ||
// Created by ChatGPT on 2025-04-02. |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.
// Created by ChatGPT on 2025-04-02. | |
// Created by ChatGPT on 2024-04-02. |
Copilot uses AI. Check for mistakes.
// PollComposerView.swift | ||
// damus | ||
// | ||
// Created by ChatGPT on 2025-04-02. |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.
// Created by ChatGPT on 2025-04-02. | |
// Created by ChatGPT on 2024-04-02. |
Copilot uses AI. Check for mistakes.
// PollVoteBuilder.swift | ||
// damus | ||
// | ||
// Created by ChatGPT on 2025-04-02. |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.
// Created by ChatGPT on 2025-04-02. | |
// Created by ChatGPT on 2024-04-02. |
Copilot uses AI. Check for mistakes.
// PollResultsStore.swift | ||
// damus | ||
// | ||
// Created by ChatGPT on 2025-04-02. |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.
// Created by ChatGPT on 2025-04-02. | |
// Created by ChatGPT on 2024-06-10. |
Copilot uses AI. Check for mistakes.
// PollModels.swift | ||
// damus | ||
// | ||
// Created by ChatGPT on 2025-04-02. |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.
// Created by ChatGPT on 2025-04-02. | |
// Created by ChatGPT on 2024-06-10. |
Copilot uses AI. Check for mistakes.
// PollDraft.swift | ||
// damus | ||
// | ||
// Created by ChatGPT on 2025-04-02. |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The creation date 2025-04-02 appears to be in the future relative to when this was likely created. Consider updating to the actual creation date.
// Created by ChatGPT on 2025-04-02. | |
// Created by ChatGPT on 2024-04-02. |
Copilot uses AI. Check for mistakes.
• Add unit tests • Add poll rendering across timeline/profile flows
can you clarify what you mean by untested? does it work ? |
The initial commit was untested as I produced the code on a Linux machine. Afterwards, I ported the PR to a macOS with Xcode. The subsequent commits ensures that the build compiles and that polls events can be both generated, and seen. I have confirmed that creating polls, and seeing polls, and responding to polls works on the latest commit. The PR is ready for your review. |
Yes, nip-88 polls worked for me on xcode iOS simulator |
Summary
-Added NIP-88 poll event kinds and a shared PollResultsStore, wiring poll support through DamusState, HeadlessDamusState, and the notification extension.
subscriptions.
for polls.
Checklist
Closes:
orFixes:
tags in the commit messages wherever applicable, or made sure those are not needed. See Submitting patchesTest report
Please provide a test report for the changes in this PR. You can use the template below, but feel free to modify it as needed.
Device: [Please specify the device you used for testing]
iOS: [Please specify the iOS version you used for testing]
Damus: [Please specify the Damus version or commit hash you used for testing]
Setup: [Please provide a brief description of the setup you used for testing, if applicable]
Steps: [Please provide a list of steps you took to test the changes in this PR]
Results:
Other notes
[Please provide any other information that you think is relevant to this PR.]