mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user