From b17daf79b16d35d564192dcdc3b22167d0cd973e Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 1 Sep 2023 12:20:45 -0400 Subject: [PATCH] MM-49393 Remove Utils.isMobile (#24271) * Switch Utils.isMobile to getIsMobileView in most places * Copy Utils.isMobile into menu widgets * Actually remove Utils.isMobile * Remove pointless checkAndSetMobileView action * Fix incorrect import of UserProfile * Fix unit test --- .../components/actions_menu/actions_menu.tsx | 2 - .../admin_console/admin_sidebar/index.ts | 7 +- .../channel_info_rhs/about_area_gm.test.tsx | 5 ++ .../linking_landing_page.tsx | 4 +- .../components/search_bar/search_bar.test.tsx | 8 --- .../components/sidebar_right_menu/index.ts | 2 + .../sidebar_right_menu/sidebar_right_menu.tsx | 6 +- .../src/components/team_general_tab/index.ts | 3 + .../team_general_tab.test.tsx | 1 + .../team_general_tab/team_general_tab.tsx | 8 +-- .../virtualized_thread_viewer/index.ts | 4 +- .../virtualized_thread_viewer.test.tsx | 2 +- .../virtualized_thread_viewer.tsx | 23 ++----- .../src/components/user_profile/index.ts | 4 +- .../user_profile/user_profile.test.tsx | 1 + .../components/user_profile/user_profile.tsx | 6 +- .../components/user_settings/general/index.ts | 6 +- .../general/user_settings_general.test.tsx | 1 + .../general/user_settings_general.tsx | 15 +++-- .../widgets/menu/is_mobile_view_hack.ts | 15 +++++ .../src/components/widgets/menu/menu.scss | 14 ++++ .../src/components/widgets/menu/menu.test.tsx | 66 ++----------------- .../src/components/widgets/menu/menu.tsx | 20 +++--- .../menu/menu_items/submenu_item.test.tsx | 4 ++ .../widgets/menu/menu_items/submenu_item.tsx | 7 +- .../submenu_modal/submenu_modal.test.tsx | 6 +- .../widgets/menu/menu_wrapper_animation.tsx | 2 +- .../channels/src/selectors/onboarding.test.ts | 25 +++++++ webapp/channels/src/selectors/onboarding.ts | 9 ++- webapp/channels/src/utils/utils.tsx | 10 +-- 30 files changed, 143 insertions(+), 143 deletions(-) create mode 100644 webapp/channels/src/components/widgets/menu/is_mobile_view_hack.ts diff --git a/webapp/channels/src/components/actions_menu/actions_menu.tsx b/webapp/channels/src/components/actions_menu/actions_menu.tsx index ec540a994a..cbd8ba2281 100644 --- a/webapp/channels/src/components/actions_menu/actions_menu.tsx +++ b/webapp/channels/src/components/actions_menu/actions_menu.tsx @@ -273,8 +273,6 @@ export class ActionMenuClass extends React.PureComponent { return null; } - // const isMobile = this.props.isMobileView TODO; - const pluginItems = this.props.pluginMenuItems?. filter((item) => { return item.filter ? item.filter(this.props.post.id) : item; diff --git a/webapp/channels/src/components/admin_console/admin_sidebar/index.ts b/webapp/channels/src/components/admin_console/admin_sidebar/index.ts index 5873ce4e61..dd3c2997da 100644 --- a/webapp/channels/src/components/admin_console/admin_sidebar/index.ts +++ b/webapp/channels/src/components/admin_console/admin_sidebar/index.ts @@ -15,10 +15,9 @@ import {ActionFunc} from 'mattermost-redux/types/actions'; import {GlobalState} from 'types/store'; -import {isMobile} from 'utils/utils'; - -import {getNavigationBlocked} from 'selectors/views/admin'; import {getAdminDefinition, getConsoleAccess} from 'selectors/admin_console'; +import {getNavigationBlocked} from 'selectors/views/admin'; +import {getIsMobileView} from 'selectors/views/browser'; import {OnboardingTaskCategory, OnboardingTaskList} from 'components/onboarding_tasks'; @@ -33,7 +32,7 @@ function mapStateToProps(state: GlobalState) { const consoleAccess = getConsoleAccess(state); const taskListStatus = getBool(state, OnboardingTaskCategory, OnboardingTaskList.ONBOARDING_TASK_LIST_SHOW); const isUserFirstAdmin = isFirstAdmin(state); - const isMobileView = isMobile(); + const isMobileView = getIsMobileView(state); const showTaskList = isUserFirstAdmin && taskListStatus && !isMobileView; const subscriptionProduct = getSubscriptionProduct(state); diff --git a/webapp/channels/src/components/channel_info_rhs/about_area_gm.test.tsx b/webapp/channels/src/components/channel_info_rhs/about_area_gm.test.tsx index 02664431c0..ce9e03dfe8 100644 --- a/webapp/channels/src/components/channel_info_rhs/about_area_gm.test.tsx +++ b/webapp/channels/src/components/channel_info_rhs/about_area_gm.test.tsx @@ -107,6 +107,11 @@ const initialState = { config: {PostEditTimeLimit: -1}, }, }, + views: { + browser: { + windowSize: '', + }, + }, }; describe('channel_info_rhs/about_area_gm', () => { diff --git a/webapp/channels/src/components/linking_landing_page/linking_landing_page.tsx b/webapp/channels/src/components/linking_landing_page/linking_landing_page.tsx index 9e63dd0ad3..f86e22eab1 100644 --- a/webapp/channels/src/components/linking_landing_page/linking_landing_page.tsx +++ b/webapp/channels/src/components/linking_landing_page/linking_landing_page.tsx @@ -160,14 +160,14 @@ export default class LinkingLandingPage extends PureComponent { renderGoNativeAppMessage = () => { return ( { this.setPreference(LandingPreferenceTypes.MATTERMOSTAPP, true); }} onClick={() => { this.setPreference(LandingPreferenceTypes.MATTERMOSTAPP, true); this.setState({redirectPage: true, navigating: true}); - if (Utils.isMobile()) { + if (UserAgent.isMobile()) { if (UserAgent.isAndroidWeb()) { const timeout = setTimeout(() => { window.location.replace(this.getDownloadLink()!); diff --git a/webapp/channels/src/components/search_bar/search_bar.test.tsx b/webapp/channels/src/components/search_bar/search_bar.test.tsx index 4e5f308435..2827134e24 100644 --- a/webapp/channels/src/components/search_bar/search_bar.test.tsx +++ b/webapp/channels/src/components/search_bar/search_bar.test.tsx @@ -22,14 +22,6 @@ const suggestionProviders = [ new SearchUserProvider(jest.fn()), ]; -jest.mock('utils/utils', () => { - const original = jest.requireActual('utils/utils'); - return { - ...original, - isMobile: jest.fn(() => false), - }; -}); - const wrapIntl = (component: JSX.Element) => ( { return (