Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
feat: warning for mobile users (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 authored Apr 3, 2019
1 parent 3f39758 commit d204f41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ export const getSampleInvoice = symbol => {
return symbol === 'BTC' ? bitcoinInvoice : litecoinInvoice;
};

/**
* Get the fee estimation from the Boltz API
*/
export const getFeeEstimation = callback => {
const url = `${boltzApi}/getfeeestimation`;
return () => {
Expand All @@ -150,9 +153,19 @@ export const getFeeEstimation = callback => {
};
};

/**
* Detect whether the browser is a mobile one
*/
export const isMobileBrowser = () => {
return (
typeof window.orientation !== 'undefined' ||
navigator.userAgent.indexOf('IEMobile') !== -1
);
};

/**
* @param {{message: string, title: string }} info title and message
* @param {number} type type of alert
* @param {number} alertType type of alert
*/
export const notificationData = (info, alertType) => {
let type;
Expand All @@ -167,6 +180,7 @@ export const notificationData = (info, alertType) => {
type = 'success';
break;
}

return {
message: info.message,
title: info.title,
Expand Down
10 changes: 9 additions & 1 deletion src/views/landingpage/landingpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@ import TaskBar from '../../components/taskbar';
import SwapTab from '../../components/swaptab';
import ModalComponent from '../../components/modal';
import BackGround from '../../components/background';
import { notificationData } from '../../scripts/utils';
import { bitcoinNetwork, litecoinNetwork } from '../../constants';
import { notificationData, isMobileBrowser } from '../../scripts/utils';

const boltz_logo = require('../../asset/icons/boltz_logo.png');

class LandingPage extends React.Component {
constructor(props) {
super(props);

this.state = {
isOpen: false,
};
this.notificationDom = React.createRef();
}

componentDidMount = () => {
if (isMobileBrowser()) {
window.alert(
// eslint-disable-next-line max-len
'We strongly advise against using Boltz on mobile devices as of right now. Please use a desktop or laptop'
);
}

this.props.getPairs();

try {
Expand Down

0 comments on commit d204f41

Please sign in to comment.