Skip to content
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

Use Linking to support URLs using default browser #1303

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions app/components/UI/DrawerView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import {
Alert,
Clipboard,
Linking,
Platform,
TouchableOpacity,
View,
Expand Down Expand Up @@ -285,6 +286,8 @@ const drawerBg = require('../../../images/drawer-bg.png'); // eslint-disable-lin
const instapay_logo_selected = require('../../../images/mm-instapay-selected.png'); // eslint-disable-line
const instapay_logo = require('../../../images/mm-instapay.png'); // eslint-disable-line

const USE_EXTERNAL_LINKS = Platform.OS === 'android' || false;

/**
* View component that displays the MetaMask fox
* in the middle of the screen
Expand Down Expand Up @@ -587,10 +590,22 @@ class DrawerView extends PureComponent {
closeSubmitFeedback = () => {
this.setState({ submitFeedback: false });
};

handleURL = url => {
const handleError = error => {
console.log(error);
this.closeSubmitFeedback();
};
if (USE_EXTERNAL_LINKS) {
Linking.openURL(url)
.then(this.closeSubmitFeedback)
.catch(handleError);
} else {
this.goToBrowserUrl(url, strings('drawer.submit_bug'));
this.closeSubmitFeedback();
}
};
goToBugFeedback = () => {
this.goToBrowserUrl(`https://metamask.zendesk.com/hc/en-us/requests/new`, strings('drawer.submit_bug'));
this.setState({ submitFeedback: false });
this.handleURL('https://metamask.zendesk.com/hc/en-us/requests/new');
};

goToGeneralFeedback = () => {
Expand All @@ -603,11 +618,9 @@ class DrawerView extends PureComponent {
const buildNumber = await getBuildNumber();
const systemName = await getSystemName();
const systemVersion = systemName === 'Android' ? await getApiLevel() : await getSystemVersion();
this.goToBrowserUrl(
`https://docs.google.com/forms/d/e/${formId}/viewform?entry.649573346=${systemName}+${systemVersion}+MM+${appVersion}+(${buildNumber})`,
strings('drawer.feedback')
this.handleURL(
`https://docs.google.com/forms/d/e/${formId}/viewform?entry.649573346=${systemName}+${systemVersion}+MM+${appVersion}+(${buildNumber})`
);
this.setState({ submitFeedback: false });
};

showHelp = () => {
Expand Down