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

[DTRA] henry/dtra-1448/enable-landscape-blocker-dtrader #16119

Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import React from 'react';
import { useLocation } from 'react-router-dom';
import { isDisabledLandscapeBlockerRoute, isTabletOs, routes } from '@deriv/shared';
import { isDisabledLandscapeBlockerRoute, isMobileOs, isTabletOs, routes } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import LandscapeBlockerSvg from 'Assets/SvgComponents/settings/landscape-blocker.svg';
import './landscape-blocker.scss';
import { useDevice } from '@deriv-com/ui';

const LandscapeBlocker = observer(() => {
// need to check for wallet account and don't hide landscape blocker for users migrated to wallets
const {
client: { has_wallet },
} = useStore();
const { isMobile } = useDevice();
const location = useLocation();
const pathname = location?.pathname;
const is_hidden_landscape_blocker = isDisabledLandscapeBlockerRoute(pathname);
const shouldShowDtraderTabletView = pathname === routes.trade && isTabletOs;
const showBlockerDtraderMobileLandscapeView = !isMobile && isMobileOs() && pathname.startsWith(routes.trade);

if (!has_wallet && (is_hidden_landscape_blocker || shouldShowDtraderTabletView)) return null;
if (
!has_wallet &&
!showBlockerDtraderMobileLandscapeView &&
(is_hidden_landscape_blocker || shouldShowDtraderTabletView)
)
return null;

return (
<div id='landscape_blocker' className='landscape-blocker'>
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/utils/os/os_detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const isDesktopOs = () => {
};

export const isMobileOs = () =>
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
(/android/i.test(navigator.userAgent.toLowerCase()) && /mobile/i.test(navigator.userAgent.toLowerCase())) ||
/webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);

export const isTabletOs =
/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()) ||
Expand Down
Loading