summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authoranderklander <anderklander@gmail.com>2017-11-14 18:50:21 +0100
committerErik Larkö <erik@mullvad.net>2017-12-14 09:16:50 +0100
commited657f7892eb9263e15a0cf2ffb0caa60b32491c (patch)
tree789a9dcdf150b7e5f9df098c2d1ae3a7680255ad /app
parent7c3d84ac86a5a29cbb456dbdce2f7af9696021cf (diff)
downloadmullvadvpn-ed657f7892eb9263e15a0cf2ffb0caa60b32491c.tar.xz
mullvadvpn-ed657f7892eb9263e15a0cf2ffb0caa60b32491c.zip
Links/exit in platform.js
moved separate small files to platform.js to handle platform specific tasks
Diffstat (limited to 'app')
-rw-r--r--app/containers/AccountPage.js4
-rw-r--r--app/containers/ConnectPage.js5
-rw-r--r--app/containers/LoginPage.js8
-rw-r--r--app/containers/SettingsPage.js9
-rw-r--r--app/lib/exit.android.js6
-rw-r--r--app/lib/exit.js6
-rw-r--r--app/lib/linking.android.js7
-rw-r--r--app/lib/linking.js7
-rw-r--r--app/lib/platform.android.js13
-rw-r--r--app/lib/platform.js13
10 files changed, 36 insertions, 42 deletions
diff --git a/app/containers/AccountPage.js b/app/containers/AccountPage.js
index ae992bc12a..4ef7de5d83 100644
--- a/app/containers/AccountPage.js
+++ b/app/containers/AccountPage.js
@@ -6,7 +6,7 @@ import { push } from 'react-router-redux';
import Account from '../components/Account';
import accountActions from '../redux/account/actions';
import { links } from '../config';
-import Linking from '../lib/linking';
+import { open } from '../lib/platform';
import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';
@@ -22,7 +22,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) =>
onClose: () => {
pushHistory('/settings');
},
- onBuyMore: () => Linking(links['purchase'])
+ onBuyMore: () => open(links['purchase'])
};
};
diff --git a/app/containers/ConnectPage.js b/app/containers/ConnectPage.js
index 1694e84556..6db84a7680 100644
--- a/app/containers/ConnectPage.js
+++ b/app/containers/ConnectPage.js
@@ -6,7 +6,7 @@ import { push } from 'react-router-redux';
import { links } from '../config';
import Connect from '../components/Connect';
import connectActions from '../redux/connection/actions';
-import Linking from '../lib/linking';
+import { open } from '../lib/platform';
import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';
@@ -25,6 +25,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) =>
const { backend } = props;
return {
+<<<<<<< HEAD
onSettings: () => {
pushHistory('/settings');
},
@@ -40,7 +41,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) =>
onDisconnect: () => {
disconnect(backend);
},
- onExternalLink: (type) => Linking(links[type]),
+ onExternalLink: (type) => open(links[type]),
getServerInfo: (relayLocation) => backend.serverInfo(relayLocation),
};
};
diff --git a/app/containers/LoginPage.js b/app/containers/LoginPage.js
index 16703fdc0c..bf1a7fdc70 100644
--- a/app/containers/LoginPage.js
+++ b/app/containers/LoginPage.js
@@ -1,16 +1,12 @@
-<<<<<<< HEAD
// @flow
-import { shell } from 'electron';
-=======
->>>>>>> Reactxp starter pack
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { push } from 'react-router-redux';
import Login from '../components/Login';
import accountActions from '../redux/account/actions';
import { links } from '../config';
-import Linking from '../lib/linking';
+import { open } from '../lib/platform';
import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';
@@ -30,7 +26,7 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: SharedRouteProps) =>
onFirstChangeAfterFailure: () => {
resetLoginError();
},
- onExternalLink: (type) => Linking(links[type]),
+ onExternalLink: (type) => open(links[type]),
onAccountTokenChange: (token) => {
updateAccountToken(token);
},
diff --git a/app/containers/SettingsPage.js b/app/containers/SettingsPage.js
index 8d41efd4d9..351c819b40 100644
--- a/app/containers/SettingsPage.js
+++ b/app/containers/SettingsPage.js
@@ -1,13 +1,10 @@
// @flow
import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux';
import { push } from 'react-router-redux';
import Settings from '../components/Settings';
-import settingsActions from '../redux/settings/actions';
import { links } from '../config';
-import Linking from '../lib/linking';
-import Exit from '../lib/exit';
+import { open, exit } from '../lib/platform';
import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';
@@ -16,12 +13,12 @@ const mapStateToProps = (state: ReduxState) => state;
const mapDispatchToProps = (dispatch: ReduxDispatch, _props: SharedRouteProps) => {
const { push: pushHistory } = bindActionCreators({ push }, dispatch);
return {
- onQuit: () => Exit(),
+ onQuit: () => exit(),
onClose: () => pushHistory('/connect'),
onViewAccount: () => pushHistory('/settings/account'),
onViewSupport: () => pushHistory('/settings/support'),
onViewAdvancedSettings: () => pushHistory('/settings/advanced'),
- onExternalLink: (type) => Linking(links[type]),
+ onExternalLink: (type) => open(links[type]),
};
};
diff --git a/app/lib/exit.android.js b/app/lib/exit.android.js
deleted file mode 100644
index 4ec175203e..0000000000
--- a/app/lib/exit.android.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// @flow
-import { BackHandler } from 'react-native';
-
-module.exports = function () {
- BackHandler.exitApp();
-}
diff --git a/app/lib/exit.js b/app/lib/exit.js
deleted file mode 100644
index 95485a7cef..0000000000
--- a/app/lib/exit.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// @flow
-import { remote } from 'electron';
-
-module.exports = function () {
- remote.app.quit();
-}
diff --git a/app/lib/linking.android.js b/app/lib/linking.android.js
deleted file mode 100644
index f694f7685c..0000000000
--- a/app/lib/linking.android.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// @flow
-import { Linking } from 'react-native';
-
-var open = (link) => {
- Linking.openURL(link);
-};
-export default open;
diff --git a/app/lib/linking.js b/app/lib/linking.js
deleted file mode 100644
index ccbedde767..0000000000
--- a/app/lib/linking.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// @flow
-import { shell } from 'electron';
-
-var open = (link) => {
- shell.openExternal(link);
-};
-export default open; \ No newline at end of file
diff --git a/app/lib/platform.android.js b/app/lib/platform.android.js
new file mode 100644
index 0000000000..f1f286826b
--- /dev/null
+++ b/app/lib/platform.android.js
@@ -0,0 +1,13 @@
+// @flow
+import { BackHandler } from 'react-native';
+import { Linking } from 'react-native';
+
+const exit = () => {
+ BackHandler.exitApp();
+};
+
+const open = (link) => {
+ Linking.openURL(link);
+};
+
+export {exit, open}; \ No newline at end of file
diff --git a/app/lib/platform.js b/app/lib/platform.js
new file mode 100644
index 0000000000..868a24e588
--- /dev/null
+++ b/app/lib/platform.js
@@ -0,0 +1,13 @@
+// @flow
+import { remote } from 'electron';
+import { shell } from 'electron';
+
+const exit = () => {
+ remote.app.quit();
+};
+
+const open = (link) => {
+ shell.openExternal(link);
+};
+
+export {exit, open}; \ No newline at end of file