-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: added web redirect #2087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ajit/fix-fetch-auth-config
Are you sure you want to change the base?
feat: added web redirect #2087
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import alert from "dialogs/alert"; | |
| import DOMPurify from "dompurify"; | ||
| import Ref from "html-tag-js/ref"; | ||
| import actionStack from "lib/actionStack"; | ||
| import auth from "lib/auth"; | ||
| import config from "lib/config"; | ||
| import helpers from "utils/helpers"; | ||
| import Url from "utils/Url"; | ||
|
|
@@ -271,6 +272,7 @@ function handleTabClick(e) { | |
| } | ||
|
|
||
| function Buttons({ | ||
| id, | ||
| name, | ||
| isPaid, | ||
| installed, | ||
|
|
@@ -283,6 +285,25 @@ function Buttons({ | |
| minVersionCode, | ||
| isSupported = true, | ||
| }) { | ||
| async function openPluginWebsite() { | ||
| const user = await auth.getLoggedInUser(); | ||
| if (!user) { | ||
| CustomTabs.open( | ||
| `${config.BASE_URL}/login?redirect=app`, | ||
| { showTitle: true }, | ||
| () => {}, | ||
| () => {}, | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| CustomTabs.open( | ||
| `${config.BASE_URL}/plugin/${id}`, | ||
| { showTitle: true }, | ||
| () => {}, | ||
| () => {}, | ||
| ); | ||
| } | ||
|
Comment on lines
+288
to
+306
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (!isSupported) { | ||
| return ( | ||
| <div | ||
|
|
@@ -346,6 +367,19 @@ function Buttons({ | |
| ); | ||
| } | ||
|
|
||
| if (!config.IAP_AVAILABLE && isPaid && !purchased && price) { | ||
| return ( | ||
| <button | ||
| data-type="buy" | ||
| className="btn btn-install" | ||
| onclick={openPluginWebsite} | ||
| > | ||
| <i className="icon open_in_browser"></i> | ||
| {price} | ||
| </button> | ||
| ); | ||
| } | ||
|
Comment on lines
+370
to
+381
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| if (isPaid && !purchased && price) { | ||
| return ( | ||
| <button data-type="buy" className="btn btn-install" onclick={buy}> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ export default function Item({ | |
| className="list-item" | ||
| data-action="open" | ||
| data-installed={(!!installed).toString()} | ||
| data-paid={(price > 0).toString()} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| style={enabled === false ? { opacity: 0.6 } : {}} | ||
| > | ||
| <div className="plugin-header"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import alert from "dialogs/alert"; | |
| import prompt from "dialogs/prompt"; | ||
| import select from "dialogs/select"; | ||
| import purchaseListener from "handlers/purchase"; | ||
| import auth from "lib/auth"; | ||
| import config from "lib/config"; | ||
| import InstallState from "lib/installState"; | ||
| import loadPlugin from "lib/loadPlugin"; | ||
|
|
@@ -772,6 +773,27 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) { | |
| }); | ||
|
|
||
| const isPaid = remotePlugin.price > 0; | ||
| if (isPaid && !config.IAP_AVAILABLE) { | ||
| const user = await auth.getLoggedInUser(); | ||
| if (!user) { | ||
| CustomTabs.open( | ||
| `${config.BASE_URL}/login?redirect=app`, | ||
| { showTitle: true }, | ||
| () => {}, | ||
| () => {}, | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| CustomTabs.open( | ||
| `${config.BASE_URL}/plugin/${remotePlugin.id}`, | ||
| { showTitle: true }, | ||
| () => {}, | ||
| () => {}, | ||
| ); | ||
| return; | ||
| } | ||
|
Comment on lines
775
to
+795
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Consider checking |
||
|
|
||
| if (isPaid) { | ||
| [product] = await helpers.promisify(iap.getProducts, [ | ||
| remotePlugin.sku, | ||
|
|
@@ -781,7 +803,6 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) { | |
| purchaseToken = purchase?.purchaseToken; | ||
| } | ||
| } | ||
|
|
||
| if (isPaid && !purchaseToken) { | ||
| if (!product) throw new Error("Product not found"); | ||
| const apiStatus = await helpers.checkAPIStatus(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!config.IAP_AVAILABLEblock inbuy()is never reachedWhen
!config.IAP_AVAILABLE,plugin.view.js'sButtonscomponent renders the buy button withonclick={openPluginWebsite}(a local function), not with thebuyprop. So this guard block insidebuy()will never execute from the plugin detail page. The redirect logic for this scenario lives entirely inopenPluginWebsite; this copy adds confusion without adding safety.