Skip to content

Commit

Permalink
Merge pull request #1511 from RodriSanchez1/electron/manageSubscription
Browse files Browse the repository at this point in the history
Electron - Manage subscription
  • Loading branch information
martinbedouret authored Aug 15, 2023
2 parents 60e8d69 + 81995d5 commit b266a7c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/Settings/Settings.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import FullScreenDialog from '../UI/FullScreenDialog';
import Paper from '@material-ui/core/Paper';
import UserIcon from '../UI/UserIcon';
import SettingsTour from './SettingsTour.component';
import { isCordova, isAndroid, isElectron, isIOS } from '../../cordova-util';
import { isCordova, isAndroid, isIOS } from '../../cordova-util';

import './Settings.css';
import { CircularProgress } from '@material-ui/core';
Expand Down Expand Up @@ -98,7 +98,7 @@ export class Settings extends PureComponent {
}
];

if (!isIOS() && !isElectron() && !isInFreeCountry) {
if (!isIOS() && !isInFreeCountry) {
const subscribeSection = {
icon: <MonetizationOnIcon />,
text: messages.subscribe,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Settings/Subscribe/Subscribe.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export const INCLUDED_FEATURES = [
export const ERROR = 'error';
export const EMPTY_PRODUCT = 'empty_product';
export const ON_TRIAL_PERIOD = 'on_trial_period';
export const GOOGLE_PLAY_STORE_URL =
'https://play.google.com/store/account/subscriptions';
17 changes: 11 additions & 6 deletions src/components/Settings/Subscribe/SubscriptionInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import {

import RefreshIcon from '@material-ui/icons/Refresh';
import IconButton from '../../UI/IconButton';
import { isAndroid } from '../../../cordova-util';
import { isAndroid, isElectron } from '../../../cordova-util';
import { GOOGLE_PLAY_STORE_URL } from './Subscribe.constants';

const propTypes = {
ownedProduct: PropTypes.object.isRequired,
Expand Down Expand Up @@ -138,11 +139,15 @@ const SubscriptionInfo = ({
if (isAndroid() && ownedProduct.platform === 'android-playstore')
window.CdvPurchase.store.manageSubscriptions();
if (ownedProduct.platform === 'paypal') setCancelDialog(true);
if (!isAndroid() && ownedProduct.platform === 'android-playstore')
window.open(
'https://play.google.com/store/account/subscriptions',
'_blank'
);
if (!isAndroid() && ownedProduct.platform === 'android-playstore') {
if (isElectron()) {
window.cordova.plugins.DefaultBrowser.open(
GOOGLE_PLAY_STORE_URL
);
} else {
window.open(GOOGLE_PLAY_STORE_URL, '_blank');
}
}
}}
style={{ marginLeft: '1em' }}
>
Expand Down
17 changes: 16 additions & 1 deletion src/components/Settings/Subscribe/SubscriptionPlans.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ON_TRIAL_PERIOD
} from './Subscribe.constants';
import { formatDuration, formatTitle } from './Subscribe.helpers';
import { isAndroid, isCordova } from '../../../cordova-util';
import { isAndroid, isCordova, isElectron } from '../../../cordova-util';
import { CircularProgress } from '@material-ui/core';

import { Link } from 'react-router-dom';
Expand Down Expand Up @@ -245,6 +245,21 @@ const SubscriptionPlans = ({
<FormattedMessage {...messages.subscribe} />
</Button>
)}
{isElectron() && (
<Button
variant="contained"
fullWidth={true}
color="primary"
onClick={function() {
window.cordova.plugins.DefaultBrowser.open(
'https://app.cboard.io/settings/subscribe'
);
}}
disabled={!canPurchase}
>
<FormattedMessage {...messages.subscribe} />
</Button>
)}
{!isCordova() && !isLogged && (
<Button
variant="contained"
Expand Down

0 comments on commit b266a7c

Please sign in to comment.