purple: add scalable tenure star badges (1–10 stars)#3592
purple: add scalable tenure star badges (1–10 stars)#3592alltheseas wants to merge 2 commits intodamus-io:masterfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughParses server flags into extended PurpleAccountAttributes (adds three‑year flag), selects a triple‑star supporter badge variant with accessibility labels, adds unit tests for attribute parsing, and updates Xcode project entries including a Swift package reference rename and test file inclusion. Changes
Sequence Diagram(s)sequenceDiagram
participant Server as Server
participant AccountModel as Account.Model
participant Badge as SupporterBadge
participant View as BadgeView
Server->>AccountModel: send JSON payload with attributes
activate AccountModel
AccountModel->>AccountModel: parse payload into Payload.Attributes
AccountModel->>AccountModel: compute PurpleAccountAttributes (one‑year, three‑year)
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 special
else none
Badge->>View: render normal badge
end
Badge->>View: set accessibilityLabel (variant-specific)
deactivate Badge
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (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.
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)) }
c03fd23 to
919c474
Compare
|
Addressed coderabbit nitpick comments:
All 5 tests pass. |
Return the new member_for_more_than_three_years boolean in the account attributes response. Uses the same 360-day-year convention as the existing one-year check (3 × 360 = 1080 days). The total membership time is now computed once and reused for both thresholds. Companion to damus-io/damus#3592. Signed-off-by: alltheseas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Companion API PR: damus-io/api#27 — adds the |
Return the new member_for_more_than_three_years boolean in the account attributes response. Uses the same 360-day-year convention as the existing one-year check (3 × 360 = 1080 days). The total membership time is now computed once and reused for both thresholds. Companion to damus-io/damus#3592. Signed-off-by: alltheseas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
944d7da to
0ea39fd
Compare
|
Closing in favor of consolidated Linux-style topic branches. This work will be audited against AGENTS.md requirements and cherry-picked into ordered topic branches. See #3624 for tracking. |
0ea39fd to
9dd160e
Compare
9dd160e to
864eb54
Compare
Replace the PurpleAccountAttributes OptionSet with a single active_membership_duration TimeInterval (seconds) from the API. Backward compatible: falls back to the member_for_more_than_one_year boolean when the duration field is absent, and handles null/missing attributes gracefully. Closes: damus-io#3591 Changelog-Added: Add tenure star badges for Purple members (1 star per year, up to 10) Signed-off-by: elsat <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace DoubleStar and BadgeVariant enum with a single MultiStar(count:) view driven by a star_count computed property (1 per year, capped at 10). MultiStarShape uses a loop over path operations (iOS 17+) with an iOS 16 fallback using ForEach. Adds accessibility labels. Signed-off-by: elsat <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
864eb54 to
b2d6d35
Compare
danieldaquino
left a comment
There was a problem hiding this comment.
10 stars seems a bit too much. @jb55, is this desired behaviour? Can you please confirm your new requirements?




Commits (review commit-by-commit)
b9c1ecfe— purple: replace boolean tenure attributes with int duration (+23 impl, +89 test)b2d6d350— purple: generalize star badges to support 1–10 stars (+90 impl, +22 test)Total: 113 impl, 111 test
Summary
Replace individual boolean tenure flags (
member_for_more_than_one_year) with a singleactive_membership_durationinteger (seconds) from the API. Badge tier is now computed client-side: one star per year of membership, up to 10.Commit 1 swaps the
PurpleAccountAttributesOptionSet for aTimeIntervalproperty, with backward-compatible decoding (falls back to the old boolean when the duration field is absent).Commit 2 replaces the hardcoded
DoubleStar/BadgeVariantenum with a generalizedMultiStar(count:)view that handles any star count via path operations (iOS 17+) with an iOS 16 fallback.Companion PR
API server: damus-io/api#27
Checklist
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. Manually tested 1, 2, 3, 4, 5, and 10 star scenarios on simulator.
Steps:
Results:
Other notes
The Purple API server needs to return
active_membership_duration(seconds) in the attributes payload. See companion PR above. The client falls back to the oldmember_for_more_than_one_yearboolean for backward compatibility with older server versions.Closes: #3591