Skip to content

Commit

Permalink
[DTRA] henry/dtra-1448/enable-landscape-blocker-dtrader (#16119)
Browse files Browse the repository at this point in the history
* fix: test

* fix: show blocker for dtrader mobile landscape view

* fix: add console log for browserstack

* fix: remove logic that was blocking on tablet

* fix: remove console log

* fix: console.log

* fix: remove ipad from checking for mobileOS

* fix: add checkfor android mobile check

* fix: console log useragent

* fix: put exclusive check for mobile when os is android

* fix: remove console log

* fix: remove mobile from regex

* fix: change link filtering logic

* fix: add blocker for reports and contract details

* fix: add blocker for reports and contract details
  • Loading branch information
henry-deriv authored Jul 26, 2024
1 parent bdebbf3 commit 563e0b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
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) || pathname.startsWith(routes.reports || pathname.startsWith('/contract/')));

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

0 comments on commit 563e0b7

Please sign in to comment.