Skip to content
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

Possible Meet SubscriptionStoreView .subscriptionStatusTask bug #6

Open
simsherpa opened this issue Nov 7, 2023 · 0 comments
Open

Comments

@simsherpa
Copy link

Hello, I think I might have found a bug in the subscription check and assignment logic.

Here's what I found: The code will resolve to .success but set passStatus = .notSubscribed. That added debug print statement demonstrates that.

Sample Code:

.subscriptionStatusTask(for: passIDs.group) { taskStatus in
            self.status = await taskStatus.map { statuses in
                await ProductSubscription.shared.status(
                    for: statuses,
                    ids: passIDs
                )
            }
            switch self.status {
            case .failure(let error):
                passStatusModel.passStatus = .notSubscribed
            case .success(let status):
                passStatusModel.passStatus = status
                print("Status from subscriptionStatusTask = .success | passStatus actually set to \(passStatusModel.passStatus)")
            case .loading: break
            @unknown default
           }
       }

In my case I'm relying on these results to show/dismiss the subscription sheet -- so I modified Code as follows to correct this behavior:

switch self.status {
            case .failure(let error):
                passStatusModel.passStatus = .notSubscribed
                showSubscriptionView = true
            case .success(let status):
                passStatusModel.passStatus = status
                if passStatusModel.passStatus == .notSubscribed {
                    showSubscriptionView = true
                } else {
                    showSubscriptionView = false
                }
            case .loading: break
            @unknown default: break
            }
        }

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant