@@ -120,7 +120,9 @@ const SideNav = () => {
- {isMobile &&
sidebar.toggle()}>}
+ {isMobile && (
+
sidebar.toggle()}>
+ )}
>
);
};
diff --git a/apps/meteor/client/views/account/AccountRouter.tsx b/apps/meteor/client/views/account/AccountRouter.tsx
index b85cfcc09c442..abf1dd4775f75 100644
--- a/apps/meteor/client/views/account/AccountRouter.tsx
+++ b/apps/meteor/client/views/account/AccountRouter.tsx
@@ -2,7 +2,6 @@ import { useCurrentRoute, useRoute } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import React, { Suspense, useEffect } from 'react';
-// import { SideNav } from '../../../app/ui-utils/client';
import PageSkeleton from '../../components/PageSkeleton';
import SidenavPortal from '../../sidebar/SidenavPortal';
import AccountSidebar from './AccountSidebar';
diff --git a/apps/meteor/client/views/account/AccountSidebar.tsx b/apps/meteor/client/views/account/AccountSidebar.tsx
index 9953bd04704cd..3e5971227bde8 100644
--- a/apps/meteor/client/views/account/AccountSidebar.tsx
+++ b/apps/meteor/client/views/account/AccountSidebar.tsx
@@ -1,43 +1,28 @@
-import { useRoutePath, useCurrentRoute, useTranslation } from '@rocket.chat/ui-contexts';
-import type { ReactElement } from 'react';
-import React, { memo, useCallback, useEffect } from 'react';
+import { useRoutePath, useCurrentRoute, useTranslation, useLayout } from '@rocket.chat/ui-contexts';
+import type { FC } from 'react';
+import React, { memo } from 'react';
import { useSyncExternalStore } from 'use-sync-external-store/shim';
-import { menu, SideNav } from '../../../app/ui-utils/client';
import Sidebar from '../../components/Sidebar';
-import { isLayoutEmbedded } from '../../lib/utils/isLayoutEmbedded';
import SettingsProvider from '../../providers/SettingsProvider';
import { getAccountSidebarItems, subscribeToAccountSidebarItems } from './sidebarItems';
-const AccountSidebar = (): ReactElement => {
+const AccountSidebar: FC = () => {
const t = useTranslation();
const items = useSyncExternalStore(subscribeToAccountSidebarItems, getAccountSidebarItems);
- const closeFlex = useCallback(() => {
- if (isLayoutEmbedded()) {
- menu.close();
- return;
- }
-
- SideNav.closeFlex();
- }, []);
+ const { sidebar } = useLayout();
const currentRoute = useCurrentRoute();
- const [currentRouteName, currentRouteParams, currentQueryStringParams, currentRouteGroupName] = currentRoute;
+ const [currentRouteName, currentRouteParams, currentQueryStringParams] = currentRoute;
const currentPath = useRoutePath(currentRouteName || '', currentRouteParams, currentQueryStringParams);
- useEffect(() => {
- if (currentRouteGroupName !== 'account') {
- SideNav.closeFlex();
- }
- }, [currentRouteGroupName]);
-
// TODO: uplift this provider
return (
-
+
diff --git a/apps/meteor/client/views/admin/sidebar/AdminSidebar.tsx b/apps/meteor/client/views/admin/sidebar/AdminSidebar.tsx
index 535bff9c54856..c44338356cebd 100644
--- a/apps/meteor/client/views/admin/sidebar/AdminSidebar.tsx
+++ b/apps/meteor/client/views/admin/sidebar/AdminSidebar.tsx
@@ -1,43 +1,27 @@
-import { useRoutePath, useCurrentRoute, useTranslation } from '@rocket.chat/ui-contexts';
+import { useRoutePath, useCurrentRoute, useTranslation, useLayout } from '@rocket.chat/ui-contexts';
import type { FC } from 'react';
-import React, { useCallback, useEffect, memo } from 'react';
+import React, { memo } from 'react';
-import { menu, SideNav } from '../../../../app/ui-utils/client';
import PlanTag from '../../../components/PlanTag';
import Sidebar from '../../../components/Sidebar';
-import { isLayoutEmbedded } from '../../../lib/utils/isLayoutEmbedded';
import SettingsProvider from '../../../providers/SettingsProvider';
import AdminSidebarPages from './AdminSidebarPages';
const AdminSidebar: FC = () => {
const t = useTranslation();
- const closeAdminFlex = useCallback(() => {
- if (isLayoutEmbedded()) {
- menu.close();
- return;
- }
-
- SideNav.closeFlex();
- }, []);
+ const { sidebar } = useLayout();
const currentRoute = useCurrentRoute();
const [currentRouteName, currentRouteParams, currentQueryStringParams] = currentRoute;
const currentPath = useRoutePath(currentRouteName || '', currentRouteParams, currentQueryStringParams);
- const [, , , currentRouteGroupName] = currentRoute;
-
- useEffect(() => {
- if (currentRouteGroupName !== 'admin') {
- // SideNav.toggleFlex(-1);
- }
- }, [currentRouteGroupName]);
// TODO: uplift this provider
return (
{t('Administration')}
diff --git a/apps/meteor/client/views/omnichannel/OmnichannelRouter.tsx b/apps/meteor/client/views/omnichannel/OmnichannelRouter.tsx
index 4b299ecbe2ecd..b3edd8458091e 100644
--- a/apps/meteor/client/views/omnichannel/OmnichannelRouter.tsx
+++ b/apps/meteor/client/views/omnichannel/OmnichannelRouter.tsx
@@ -4,7 +4,7 @@ import React, { Suspense, useEffect } from 'react';
import PageSkeleton from '../../components/PageSkeleton';
import SidenavPortal from '../../sidebar/SidenavPortal';
-import OminichannelSidebar from './sidebar/OmnichannelSidebar';
+import OmnichannelSidebar from './sidebar/OmnichannelSidebar';
type OmnichannelRouterProps = {
children?: ReactNode;
@@ -24,7 +24,7 @@ const OmnichannelRouter = ({ children }: OmnichannelRouterProps): ReactElement =
<>
}>{children}
-
+
>
) : (
diff --git a/apps/meteor/client/views/omnichannel/sidebar/OmnichannelSidebar.tsx b/apps/meteor/client/views/omnichannel/sidebar/OmnichannelSidebar.tsx
index c6bde13d40826..2501d5cba4d80 100644
--- a/apps/meteor/client/views/omnichannel/sidebar/OmnichannelSidebar.tsx
+++ b/apps/meteor/client/views/omnichannel/sidebar/OmnichannelSidebar.tsx
@@ -1,12 +1,10 @@
-import { useRoutePath, useCurrentRoute, useTranslation } from '@rocket.chat/ui-contexts';
+import { useRoutePath, useCurrentRoute, useTranslation, useLayout } from '@rocket.chat/ui-contexts';
import type { FC } from 'react';
-import React, { useCallback, useEffect, memo } from 'react';
+import React, { memo } from 'react';
import { useSyncExternalStore } from 'use-sync-external-store/shim';
-import { menu, SideNav } from '../../../../app/ui-utils/client';
import Sidebar from '../../../components/Sidebar';
import SidebarItemsAssemblerProps from '../../../components/Sidebar/SidebarItemsAssembler';
-import { isLayoutEmbedded } from '../../../lib/utils/isLayoutEmbedded';
import SettingsProvider from '../../../providers/SettingsProvider';
import { getOmnichannelSidebarItems, subscribeToOmnichannelSidebarItems } from '../sidebarItems';
@@ -14,29 +12,16 @@ const OmnichannelSidebar: FC = () => {
const items = useSyncExternalStore(subscribeToOmnichannelSidebarItems, getOmnichannelSidebarItems);
const t = useTranslation();
- const closeOmnichannelFlex = useCallback(() => {
- if (isLayoutEmbedded()) {
- menu.close();
- return;
- }
-
- SideNav.closeFlex();
- }, []);
+ const { sidebar } = useLayout();
const currentRoute = useCurrentRoute();
- const [currentRouteName, currentRouteParams, currentQueryStringParams, currentRouteGroupName] = currentRoute;
+ const [currentRouteName, currentRouteParams, currentQueryStringParams] = currentRoute;
const currentPath = useRoutePath(currentRouteName ?? '', currentRouteParams, currentQueryStringParams);
- useEffect(() => {
- if (currentRouteGroupName !== 'omnichannel') {
- // SideNav.closeFlex();
- }
- }, [currentRouteGroupName]);
-
return (
- {t('Omnichannel')}>} />
+ {t('Omnichannel')}>} />
diff --git a/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.tsx b/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.tsx
index c78394a027d95..c9845e7df8efb 100644
--- a/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.tsx
+++ b/apps/meteor/client/views/root/MainLayout/LayoutWithSidebar.tsx
@@ -1,11 +1,9 @@
import { Box } from '@rocket.chat/fuselage';
-import { useLayout, useCurrentRoute, useRoutePath, useSetting, useCurrentModal } from '@rocket.chat/ui-contexts';
+import { useLayout, useCurrentRoute, useRoutePath, useSetting, useCurrentModal, useRoute } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
-import React, { useCallback } from 'react';
+import React, { useEffect, useRef } from 'react';
-import { useReactiveValue } from '../../../hooks/useReactiveValue';
import Sidebar from '../../../sidebar';
-import BlazeTemplate from '../BlazeTemplate';
const LayoutWithSidebar = ({ children }: { children: ReactNode }): ReactElement => {
const { isEmbedded: embeddedLayout } = useLayout();
@@ -13,11 +11,33 @@ const LayoutWithSidebar = ({ children }: { children: ReactNode }): ReactElement
const modal = useCurrentModal();
const currentRoutePath = useRoutePath(currentRouteName, currentParameters);
- const removeSidenav = useReactiveValue(
- useCallback(() => embeddedLayout && !currentRoutePath?.startsWith('/admin'), [currentRoutePath, embeddedLayout]),
- );
+ const channelRoute = useRoute('channel');
+ const removeSidenav = embeddedLayout && !currentRoutePath?.startsWith('/admin');
const readReceiptsEnabled = useSetting('Message_Read_Receipt_Store_Users');
+ const firstChannelAfterLogin = useSetting('First_Channel_After_Login');
+
+ const redirected = useRef(false);
+
+ useEffect(() => {
+ const needToBeRedirect = currentRoutePath && ['/', '/home'].includes(currentRoutePath);
+
+ if (!needToBeRedirect) {
+ return;
+ }
+
+ if (!firstChannelAfterLogin || typeof firstChannelAfterLogin !== 'string') {
+ return;
+ }
+
+ if (redirected.current) {
+ return;
+ }
+ redirected.current = true;
+
+ channelRoute.push({ name: firstChannelAfterLogin });
+ }, [channelRoute, currentRoutePath, firstChannelAfterLogin]);
+
return (
true,
},
- '../../../app/ui-utils/client': {
- SideNav: {},
- },
'../../../app/ui-utils/client/lib/AccountBox': {
AccountBoxItem: {},
isAppAccountBoxItem: () => false,
diff --git a/apps/meteor/tests/unit/client/components/AdministrationList/AdministrationModelList.spec.tsx b/apps/meteor/tests/unit/client/components/AdministrationList/AdministrationModelList.spec.tsx
index a9db32cad7075..1d88a460c4894 100644
--- a/apps/meteor/tests/unit/client/components/AdministrationList/AdministrationModelList.spec.tsx
+++ b/apps/meteor/tests/unit/client/components/AdministrationList/AdministrationModelList.spec.tsx
@@ -9,7 +9,6 @@ import RouterContextMock from '../../../../mocks/client/RouterContextMock';
const COMPONENT_PATH = '../../../../../client/components/AdministrationList/AdministrationModelList';
const defaultConfig = {
'../../../app/ui-utils/client': {
- 'SideNav': {},
'@noCallThru': true,
},
'meteor/kadira:flow-router': {
@@ -139,13 +138,6 @@ describe('components/AdministrationList/AdministrationModelList', () => {
const openFlex = spy();
const AdministrationModelList = proxyquire.load(COMPONENT_PATH, {
...defaultConfig,
- '../../../app/ui-utils/client': {
- 'SideNav': {
- setFlex,
- openFlex,
- },
- '@noCallThru': true,
- },
}).default;
render(
,
diff --git a/packages/ui-contexts/src/LayoutContext.ts b/packages/ui-contexts/src/LayoutContext.ts
index 0bfd009cedef4..31d278875bba3 100644
--- a/packages/ui-contexts/src/LayoutContext.ts
+++ b/packages/ui-contexts/src/LayoutContext.ts
@@ -9,7 +9,13 @@ export type LayoutContextValue = {
isEmbedded: boolean;
showTopNavbarEmbeddedLayout: boolean;
isMobile: boolean;
- sidebar: any;
+ sidebar: {
+ isCollapsed: boolean;
+ toggle: () => void;
+ collapse: () => void;
+ expand: () => void;
+ close: () => void;
+ }
size: SizeLayout;
contextualBarExpanded: boolean;
contextualBarPosition: 'absolute' | 'relative' | 'fixed';
@@ -19,7 +25,13 @@ export const LayoutContext = createContext({
isEmbedded: false,
showTopNavbarEmbeddedLayout: false,
isMobile: false,
- sidebar: {},
+ sidebar: {
+ isCollapsed: false,
+ toggle: () => { },
+ collapse: () => { },
+ expand: () => { },
+ close: () => { },
+ },
size: {
sidebar: '380px',
contextualBar: '380px',