Skip to content

feat: IAP_AVAILABLE#2086

Merged
RohitKushvaha01 merged 2 commits intoAcode-Foundation:ajit/fix-fetch-auth-configfrom
RohitKushvaha01:ajit/fix-fetch-auth-config
May 6, 2026
Merged

feat: IAP_AVAILABLE#2086
RohitKushvaha01 merged 2 commits intoAcode-Foundation:ajit/fix-fetch-auth-configfrom
RohitKushvaha01:ajit/fix-fetch-auth-config

Conversation

@RohitKushvaha01
Copy link
Copy Markdown
Member

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR introduces an IAP_AVAILABLE flag to detect whether cordova-plugin-iap is present at runtime, exposes the config object to third-party plugins via acode.define, hardens purchase-retrieval error handling, and updates the F-Droid build script to conditionally include or strip the IAP plugin.

  • IAP_AVAILABLE flag — added to config.js as typeof iap !== \"undefined\" and exposed via acode.define(\"config\", config) so plugins can query IAP availability; however, main.js never checks this flag before calling iap.startConnection, so F-Droid builds still silently error-out inside the try/catch instead of skipping the block cleanly.
  • Error handling improvementiap.getPurchases gains a .catch() that returns an empty array, but the new handler uses console.log instead of the project-standard window.log, so those errors are invisible in the app's persistent log.
  • Build scriptbuild.sh correctly removes cordova-plugin-iap on F-Droid and adds it from the local source directory on other builds.

Confidence Score: 3/5

Merging is risky for F-Droid users — the IAP_AVAILABLE guard is defined but never applied, so F-Droid builds still crash into the catch block and silently skip the entire purchase-check section.

The IAP_AVAILABLE flag is introduced but not wired into the main.js IAP block, so F-Droid builds continue to hit a TypeError on iap.startConnection and skip the pro-status logic entirely. The new getPurchases error handler also logs to console.log instead of window.log, meaning those errors won’t appear in the app’s persistent log.

src/main.js and src/lib/config.js need attention — the flag and its intended guard need to be connected.

Important Files Changed

Filename Overview
src/lib/config.js Adds IAP_AVAILABLE as a static module-level flag using typeof iap !== "undefined" — evaluated at import time, never consumed by main.js to guard IAP calls
src/main.js Adds .catch() to getPurchases but uses console.log instead of window.log; iap.startConnection is still called unconditionally without checking IAP_AVAILABLE, breaking F-Droid builds silently
src/lib/acode.js Exposes config module via acode.define so plugins can read IAP_AVAILABLE; missing space after comma is a trivial style issue
utils/scripts/build.sh Correctly removes cordova-plugin-iap on F-Droid builds and conditionally adds it from src/plugins/iap/ on non-F-Droid builds
package.json Moves com.foxdebug.acode.rk.exec.proot and cordova-plugin-iap to the end of the plugins list; removes cordova-plugin-iap from the inline config (it is now managed via build.sh)

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[onDeviceReady] --> B{F-Droid build?}
    B -- Yes --> C[iap is undefined\ncordova-plugin-iap removed]
    B -- No --> D[iap plugin present\nIAP_AVAILABLE = true]

    C --> E[iap.startConnection throws TypeError]
    E --> F[Outer catch: logs Purchase error\nIAP block entirely skipped]
    F --> G[HAS_PRO never updated\nfrom purchases]

    D --> H[iap.startConnection]
    H --> I{navigator.onLine?}
    I -- Yes --> J[iap.getPurchases\nwith new .catch returns empty array]
    J --> K{isPro found?}
    K -- Yes --> L[HAS_PRO = true]
    K -- No --> M[HAS_PRO = !isFreePackage]
    I -- No --> N[HAS_PRO unchanged]

    style C fill:#f99,stroke:#c00
    style E fill:#f99,stroke:#c00
    style F fill:#f99,stroke:#c00
Loading

Comments Outside Diff (2)

  1. src/main.js, line 198-226 (link)

    P1 IAP_AVAILABLE flag defined but never used to guard iap calls

    config.IAP_AVAILABLE is introduced in this PR but is never checked before accessing iap.startConnection or iap.getPurchases. On F-Droid builds where cordova-plugin-iap is absent, iap is undefined, so iap.startConnection throws a TypeError synchronously before the .catch() can intercept it. This causes the entire try-block to be skipped — including the localStorage.acode_pro fallback on line 204 — and the outer catch logs a "Purchase error". The newly added IAP_AVAILABLE sentinel exists but provides no protection here; wrapping the block with if (config.IAP_AVAILABLE) would cleanly skip IAP without errors on F-Droid.

  2. src/main.js, line 209-213 (link)

    P2 The new catch block uses console.log while every other error-logging call in this file (and in the startConnection catch just above it) uses window.log. This means purchase-retrieval errors will not be written to the app's persistent log file.

Reviews (1): Last reviewed commit: "fix: removed useless logs" | Re-trigger Greptile

Comment thread src/lib/acode.js
@RohitKushvaha01 RohitKushvaha01 merged commit 771af92 into Acode-Foundation:ajit/fix-fetch-auth-config May 6, 2026
6 checks passed
@RohitKushvaha01 RohitKushvaha01 deleted the ajit/fix-fetch-auth-config branch May 6, 2026 12:44
@RohitKushvaha01 RohitKushvaha01 restored the ajit/fix-fetch-auth-config branch May 6, 2026 13:41
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

Successfully merging this pull request may close these issues.

1 participant