-
Notifications
You must be signed in to change notification settings - Fork 62
IOS-5365 implement the async membership handling #4111
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: develop
Are you sure you want to change the base?
IOS-5365 implement the async membership handling #4111
Conversation
refactor the membership storage and event handling
Bugs/IssuesRace condition in event handling (MembershipStatusStorage.swift:73-91, 93-102)
Missing tiers refresh (MembershipStatusStorage.swift:55-58)
Silent error swallowing (MembershipCoordinatorModel.swift:65-68)
Best PracticesDebug print statements in production (MembershipStatusStorage.swift:76, 87, 89)
Missing error handling (MembershipStatusStorage.swift:55-58)
Summary: 🚨 Major Issues - Race conditions in event handling, incomplete refresh logic, and silent error swallowing need fixing |
var tiers: [MembershipTier] { | ||
let currentTierId = userMembership.tier?.type.id ?? 0 | ||
return allTiers | ||
.filter { FeatureFlags.membershipTestTiers || !$0.isTest } | ||
.filter { !$0.iosProductID.isEmpty || $0.type.id == currentTierId } | ||
} |
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.
If we use this on the UI level, it will really affect performance. It's better to make this a published property and discard @Published private var allTiers: [MembershipTier] = []
because seems like it's not used anymore.
Also naming is really ambiguous. We have allTiers and tiers with no significant distinction and ability to understand what is what.
} | ||
|
||
case .membershipTiersUpdate(let update): | ||
Task { |
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.
Task created inside main actor will still be called on the main actor. If you want to do it in the backgroind you need to call Task.detached
public let isTest: Bool | ||
public let iosProductID: String |
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.
We already have this properties available inside Anytype_Model_MembershipTierData I am not sure we need to introduce them here once again
) | ||
_status.tier.flatMap { AnytypeAnalytics.instance().logChangePlan(tier: $0) } | ||
AnytypeAnalytics.instance().setMembershipTier(tier: _status.tier) | ||
print("[Membership] Updated membership status - tier: \(_status.tier?.name ?? "none")") |
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.
As claude mentioned - no prints in production code. It should be either assert or remove it
Refactored membership data management to work with new middleware caching behavior for faster app startup.
Problem
Middleware now returns cached membership/tiers data immediately (with noCache: false) instead of blocking on network calls. App startup was slow because we were forcing network calls with noCache: true.
Changes
Single Source of Truth Architecture
Fast Startup
Event Handling
Tier Filtering
Files Modified