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

Updating Swaps backend controls #5194

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion app/components/UI/Swaps/SwapsLiveness.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
setSwapsLiveness,
swapsLivenessSelector,
} from '../../../reducers/swaps';
import Device from '../../../util/device';
import Logger from '../../../util/Logger';
import useInterval from '../../hooks/useInterval';
import { isSwapsAllowed } from './utils';
Expand All @@ -22,8 +23,15 @@ function SwapLiveness({ isLive, chainId, setLiveness }) {
chainId,
AppConstants.SWAPS.CLIENT_ID,
);
const isIphone = Device.isIos();
const isAndroid = Device.isAndroid();
const featureFlagKey = isIphone
? 'mobileActiveIOS'
: isAndroid
? 'mobileActiveAndroid'
: 'mobileActive';
const liveness =
typeof data === 'boolean' ? data : data?.mobileActive ?? false;
typeof data === 'boolean' ? data : data?.[featureFlagKey] ?? false;
setLiveness(liveness, chainId);
} catch (error) {
Logger.error(error, 'Swaps: error while fetching swaps liveness');
Expand Down
9 changes: 8 additions & 1 deletion app/components/UI/Swaps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,15 @@ function SwapsAmountView({
chainId,
AppConstants.SWAPS.CLIENT_ID,
);
const isIphone = Device.isIos();
const isAndroid = Device.isAndroid();
const featureFlagKey = isIphone
? 'mobileActiveIOS'
: isAndroid
? 'mobileActiveAndroid'
: 'mobileActive';
const liveness =
typeof data === 'boolean' ? data : data?.mobileActive ?? false;
typeof data === 'boolean' ? data : data?.[featureFlagKey] ?? false;
setLiveness(liveness, chainId);
if (liveness) {
// Triggered when a user enters the MetaMask Swap feature
Expand Down