Skip to content

Commit b266a7c

Browse files
Merge pull request #1511 from RodriSanchez1/electron/manageSubscription
Electron - Manage subscription
2 parents 60e8d69 + 81995d5 commit b266a7c

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

src/components/Settings/Settings.component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import FullScreenDialog from '../UI/FullScreenDialog';
2525
import Paper from '@material-ui/core/Paper';
2626
import UserIcon from '../UI/UserIcon';
2727
import SettingsTour from './SettingsTour.component';
28-
import { isCordova, isAndroid, isElectron, isIOS } from '../../cordova-util';
28+
import { isCordova, isAndroid, isIOS } from '../../cordova-util';
2929

3030
import './Settings.css';
3131
import { CircularProgress } from '@material-ui/core';
@@ -98,7 +98,7 @@ export class Settings extends PureComponent {
9898
}
9999
];
100100

101-
if (!isIOS() && !isElectron() && !isInFreeCountry) {
101+
if (!isIOS() && !isInFreeCountry) {
102102
const subscribeSection = {
103103
icon: <MonetizationOnIcon />,
104104
text: messages.subscribe,

src/components/Settings/Subscribe/Subscribe.constants.js

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ export const INCLUDED_FEATURES = [
1414
export const ERROR = 'error';
1515
export const EMPTY_PRODUCT = 'empty_product';
1616
export const ON_TRIAL_PERIOD = 'on_trial_period';
17+
export const GOOGLE_PLAY_STORE_URL =
18+
'https://play.google.com/store/account/subscriptions';

src/components/Settings/Subscribe/SubscriptionInfo.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929

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

3435
const propTypes = {
3536
ownedProduct: PropTypes.object.isRequired,
@@ -138,11 +139,15 @@ const SubscriptionInfo = ({
138139
if (isAndroid() && ownedProduct.platform === 'android-playstore')
139140
window.CdvPurchase.store.manageSubscriptions();
140141
if (ownedProduct.platform === 'paypal') setCancelDialog(true);
141-
if (!isAndroid() && ownedProduct.platform === 'android-playstore')
142-
window.open(
143-
'https://play.google.com/store/account/subscriptions',
144-
'_blank'
145-
);
142+
if (!isAndroid() && ownedProduct.platform === 'android-playstore') {
143+
if (isElectron()) {
144+
window.cordova.plugins.DefaultBrowser.open(
145+
GOOGLE_PLAY_STORE_URL
146+
);
147+
} else {
148+
window.open(GOOGLE_PLAY_STORE_URL, '_blank');
149+
}
150+
}
146151
}}
147152
style={{ marginLeft: '1em' }}
148153
>

src/components/Settings/Subscribe/SubscriptionPlans.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ON_TRIAL_PERIOD
1717
} from './Subscribe.constants';
1818
import { formatDuration, formatTitle } from './Subscribe.helpers';
19-
import { isAndroid, isCordova } from '../../../cordova-util';
19+
import { isAndroid, isCordova, isElectron } from '../../../cordova-util';
2020
import { CircularProgress } from '@material-ui/core';
2121

2222
import { Link } from 'react-router-dom';
@@ -245,6 +245,21 @@ const SubscriptionPlans = ({
245245
<FormattedMessage {...messages.subscribe} />
246246
</Button>
247247
)}
248+
{isElectron() && (
249+
<Button
250+
variant="contained"
251+
fullWidth={true}
252+
color="primary"
253+
onClick={function() {
254+
window.cordova.plugins.DefaultBrowser.open(
255+
'https://app.cboard.io/settings/subscribe'
256+
);
257+
}}
258+
disabled={!canPurchase}
259+
>
260+
<FormattedMessage {...messages.subscribe} />
261+
</Button>
262+
)}
248263
{!isCordova() && !isLogged && (
249264
<Button
250265
variant="contained"

0 commit comments

Comments
 (0)