-
Notifications
You must be signed in to change notification settings - Fork 301
Add triple star badge for three-year Purple members #3592
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?
Conversation
📝 WalkthroughWalkthroughAdds a three‑year Purple membership attribute and badge: introduces Changes
Sequence Diagram(s)sequenceDiagram
participant Server
participant AccountModel as Account.Model
participant Badge as SupporterBadge
participant View as Badge View
Server->>AccountModel: send JSON payload (attributes flags)
activate AccountModel
AccountModel->>AccountModel: parse payload, compute PurpleAccountAttributes set
AccountModel-->>Badge: provide Account with attributes
deactivate AccountModel
activate Badge
Badge->>Badge: evaluate memberForMoreThanThreeYears?
alt three-year
Badge->>View: render TripleStar
else one-year
Badge->>View: render one-year variant
else none
Badge->>View: render normal badge
end
deactivate Badge
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
|
requires Purple API change: #3591 (comment) |
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.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@damus.xcodeproj/project.pbxproj`:
- Around line 1500-1504: Remove or fix the dangling PBXBuildFile entry
D73E5EFE2C6A97F4007EB227 in the Sources build phase: either delete this build
file record (the one with isa = PBXBuildFile and no fileRef) from the
project.pbxproj and from the Sources phase list, or replace its missing fileRef
with the correct file reference to the intended source file; ensure no other
build phase entries reference the same placeholder and repeat the same cleanup
for the other occurrences noted (e.g., the similar entries around lines
7262-7266).
In `@damus/Features/Purple/Models/DamusPurple.swift`:
- Around line 474-478: Add a doc comment for the new optional field
member_for_more_than_three_years in the Attributes struct explaining what the
flag represents (e.g., true when the member has been a member for more than
three years), that it is optional/nullable, and any server semantics (when it
may be omitted); update the Attributes struct's property comments so both
member_for_more_than_one_year and member_for_more_than_three_years have concise
docstrings describing their meaning and types.
In `@damus/Shared/Components/SupporterBadge.swift`:
- Around line 176-251: Add doc comments to the newly introduced TripleStar view
internals: document the TripleStar struct (describe purpose and parameters like
size and starOffset), the nested TripleStarShape (explain strokeSize, starOffset
and what path(in:) returns), and the Fallback view (describe its behavior for
iOS <17 and parameters size and starOffset). Place concise /// comments above
TripleStar, TripleStarShape, TripleStarShape.path(in:), and Fallback explaining
intent, parameters, and platform behavior to satisfy docstring coverage
guidelines.
🧹 Nitpick comments (2)
damusTests/DamusPurpleAccountAttributesTests.swift (2)
88-110: Consider consolidating or differentiating this test.
testParseAccountWithMissingThreeYearFieldhas an identical JSON payload totestParseAccountWithOneYearAttribute(lines 40-52). While the intent differs (feature verification vs backward compatibility documentation), the tests are functionally redundant.Consider either:
- Consolidating them into a single test with clear documentation of both intents, or
- Adding a distinguishing comment to clarify why both exist.
112-133: Consider adding a test for absentattributeskey.The current tests cover
"attributes": null, but there's no test for when theattributeskey is completely absent from the JSON. Depending on howPayload.Attributesis declared, these may behave differently during JSON decoding.Suggested additional test
/// Tests backward compatibility when the attributes field is absent from the response. func testParseAccountWithAbsentAttributesField() throws { let json = """ { "pubkey": "\(testPubkeyHex)", "created_at": 1700000000, "expiry": 1800000000, "subscriber_number": 42, "active": true } """ guard let account = DamusPurple.Account.from(json_data: json.data(using: .utf8)!) else { XCTFail("Failed to parse account") return } XCTAssertFalse(account.attributes.contains(.memberForMoreThanOneYear)) XCTAssertFalse(account.attributes.contains(.memberForMoreThanThreeYears)) }
907f945 to
c03fd23
Compare
Add support for displaying a triple star badge for Purple members who have been subscribed for more than three years. Changes: - Add memberForMoreThanThreeYears attribute to PurpleAccountAttributes - Add member_for_more_than_three_years field to server response parsing - Add TripleStar view with iOS 17+ shape and iOS 16 fallback - Add threeYearSpecial badge variant - Update badge selection logic to check for three-year membership - Add tests for account attribute parsing including backward compatibility The server will need to be updated to return the new member_for_more_than_three_years field in the account attributes. Closes: damus-io#3591 Changelog-Added: Add triple star badge for three-year Purple members Signed-off-by: alltheseas <alltheseas@users.noreply.github.com>
c03fd23 to
919c474
Compare
|
Addressed coderabbit nitpick comments:
All 5 tests pass. |
Screenshot
Summary
memberForMoreThanThreeYearsattribute toPurpleAccountAttributesTripleStarview with iOS 17+ shape and iOS 16 fallbackChecklist
Standard PR Checklist
Closes:orFixes:tags in the commit messages wherever applicable, or made sure those are not needed. See Submitting patchesTest report
Device: iPhone 17 Pro Simulator
iOS: 26.2
Damus: This branch
Setup: Built and ran tests via xcodebuild
Steps:
DamusPurpleAccountAttributesTests- 5 tests for parsing account attributesmember_for_more_than_three_yearsfield is missingResults:
Other notes
The Purple API server will need to be updated to return the new
member_for_more_than_three_yearsfield in the account attributes response for this feature to work end-to-end.Closes: #3591
Summary by CodeRabbit
New Features
UI
Tests