Skip to content

Commit cc8f1fd

Browse files
authored
fix: only initiate iap stuff in case of paid plugin on sidebar (#1322)
1 parent 4395754 commit cc8f1fd

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/sidebarApps/extensions/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,14 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) {
435435
});
436436

437437
const isPaid = remotePlugin.price > 0;
438-
[product] = await helpers.promisify(iap.getProducts, [
439-
remotePlugin.sku,
440-
]);
441-
if (product) {
442-
const purchase = await getPurchase(product.productId);
443-
purchaseToken = purchase?.purchaseToken;
438+
if (isPaid) {
439+
[product] = await helpers.promisify(iap.getProducts, [
440+
remotePlugin.sku,
441+
]);
442+
if (product) {
443+
const purchase = await getPurchase(product.productId);
444+
purchaseToken = purchase?.purchaseToken;
445+
}
444446
}
445447

446448
if (isPaid && !purchaseToken) {
@@ -475,7 +477,11 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) {
475477
}
476478

477479
const { default: installPlugin } = await import("lib/installPlugin");
478-
await installPlugin(id, remotePlugin.name, purchaseToken);
480+
await installPlugin(
481+
id,
482+
remotePlugin.name,
483+
purchaseToken ? purchaseToken : undefined,
484+
);
479485

480486
const searchInput = container.querySelector('input[name="search-ext"]');
481487
if (searchInput) {

0 commit comments

Comments
 (0)