fix(native): location at the accuracy asked for, and a Play payment that clears later is redeemed

- The location shim runs at high accuracy only while a watcher wants it and
  drops back once that watcher is gone, instead of keeping the 2 s GPS rate
  for the rest of the session.
- The purchase client can hand over a Play subscription that was paid but
  never delivered (a pending payment that cleared later), and the plans screen
  redeems it at once, as a restore would, before Google Play refunds it after
  three days.
This commit is contained in:
Maurice
2026-11-07 14:57:50 +01:00
parent c1c71a12cf
commit 46f4cab1b7
6 changed files with 120 additions and 7 deletions
+17
View File
@@ -448,6 +448,10 @@ function planCard(plan: CloudPlan, interval: 'month' | 'year', offer: Offer): HT
* holds (a reinstall, a new phone). Without one: only that buying in the app is
* not available, and no pointer elsewhere.
*/
/** The restore button of the plans on screen, which redeems a payment that cleared later. */
let resumeRestore: (() => void) | null = null;
let watchingTransactions = false;
function planFooter(offer: Offer, plans: CloudPlan[]): Node[] {
if (offer.opensSoon) return [el('p', { className: 'note' }, t('native.plans.closed'))];
if (!offer.canBuy) return [el('p', { className: 'note' }, t('native.plans.soon'))];
@@ -490,6 +494,19 @@ function planFooter(offer: Offer, plans: CloudPlan[]): Node[] {
status.textContent = t('native.plans.restoreFailed');
});
// A payment that was pending (cash, some carrier billing) and has cleared since:
// redeemed right away, as the restore would, before Google Play refunds it.
resumeRestore = () => {
if (!restore.disabled && restore.isConnected) restore.click();
};
if (!watchingTransactions) {
watchingTransactions = true;
iap.onTransaction(() => resumeRestore?.());
}
void iap.unfinished().then((purchase) => {
if (purchase) resumeRestore?.();
});
return [
restore,
status,