Commit 5516697
Claude Bot
fix(billing): mark Freedom purchased BEFORE acknowledgePurchase async call
THE ACTUAL BUG (post-purchase flow):
When the user completes the Freedom purchase in the Play Billing sheet:
1. purchasesUpdatedListener fires → handlePurchase() is called
2. OLD CODE: markAsFreedomPurchased() was called only INSIDE the
acknowledgePurchase() async callback — i.e. after Google's server
round-trip (can take 1-3+ seconds)
3. MEANWHILE: onResume() fires as the app returns from the billing sheet
→ loadWebViewContent() reloads the WebView
→ queryActiveSubscriptions() runs concurrently
4. The freshly loaded WebView calls isFreedomPurchased() at DOMContentLoaded
→ SharedPrefs still says FALSE (markAsFreedomPurchased not called yet)
→ shows BUY BUTTONS instead of the Freedom confirmation card
5. queryActiveSubscriptions() may also return an empty list at this point
→ clears the mark (before today's 5s-delay fix) or does nothing wrong
6. Only AFTER acknowledgePurchase completes does markAsFreedomPurchased()
run — but the WebView has already rendered the wrong state and the
JS callback either landed on the wrong page state or got lost
FIX: Move markAsFreedomPurchased(), markAsPurchased(), updateTrialState()
and evaluateWebViewJsWithRetry(true) to BEFORE the isAcknowledged check,
so SharedPreferences is updated synchronously the instant purchaseState
== PURCHASED is confirmed. The async acknowledgePurchase() only handles
the server-side ack step now; it no longer gates any UI update.1 parent 822e3f5 commit 5516697
1 file changed
Lines changed: 11 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1255 | 1255 | | |
1256 | 1256 | | |
1257 | 1257 | | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
1258 | 1266 | | |
1259 | 1267 | | |
1260 | 1268 | | |
| |||
1265 | 1273 | | |
1266 | 1274 | | |
1267 | 1275 | | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
1273 | 1276 | | |
1274 | 1277 | | |
1275 | 1278 | | |
| |||
1281 | 1284 | | |
1282 | 1285 | | |
1283 | 1286 | | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
1288 | 1290 | | |
1289 | 1291 | | |
1290 | 1292 | | |
| |||
0 commit comments