From 6c750c665b5ee9763bb939866873689ffdc6266b Mon Sep 17 00:00:00 2001 From: Andrey Mikhadyuk Date: Wed, 13 Sep 2023 15:15:28 +0300 Subject: [PATCH] change logic of default chat size generation --- src/pages/commonFeed/CommonFeedPage.tsx | 1 - src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx | 3 +-- .../commonFeed/components/FeedLayout/utils/getDefaultSize.ts | 5 ++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pages/commonFeed/CommonFeedPage.tsx b/src/pages/commonFeed/CommonFeedPage.tsx index 39649f582f..78d6cc1f4b 100644 --- a/src/pages/commonFeed/CommonFeedPage.tsx +++ b/src/pages/commonFeed/CommonFeedPage.tsx @@ -28,7 +28,6 @@ export const FEED_LAYOUT_OUTER_STYLES: FeedLayoutOuterStyles = { export const BASE_FEED_LAYOUT_SETTINGS: FeedLayoutSettings = { withDesktopChatTitle: false, - sidenavWidth: 0, }; const renderContentWrapper: RenderCommonFeedContentWrapper = ({ diff --git a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx index c167b02997..f23cfc14c0 100644 --- a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx +++ b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx @@ -95,7 +95,6 @@ export interface FeedLayoutOuterStyles { export interface FeedLayoutSettings { withDesktopChatTitle?: boolean; - sidenavWidth?: number; getSplitViewMaxSize?: (width: number) => number; } @@ -219,7 +218,7 @@ const FeedLayout: ForwardRefRenderFunction = ( settings?.getSplitViewMaxSize?.(windowWidth) ?? getSplitViewMaxSize(windowWidth); const [realChatWidth, setRealChatWidth] = useState(() => - getDefaultSize(windowWidth, maxChatSize, settings?.sidenavWidth), + getDefaultSize(windowWidth, maxChatSize), ); const chatWidth = Math.min(realChatWidth, maxChatSize); const [expandedFeedItemId, setExpandedFeedItemId] = useState( diff --git a/src/pages/commonFeed/components/FeedLayout/utils/getDefaultSize.ts b/src/pages/commonFeed/components/FeedLayout/utils/getDefaultSize.ts index 4ba1fe0bdd..8538200193 100644 --- a/src/pages/commonFeed/components/FeedLayout/utils/getDefaultSize.ts +++ b/src/pages/commonFeed/components/FeedLayout/utils/getDefaultSize.ts @@ -4,12 +4,11 @@ import { getSavedChatSize } from "./chatSize"; export const getDefaultSize = ( windowWidth: number, maxChatSize: number, - sidenavWidth = 336, ): number => { const pageWidth = Math.min(windowWidth, 1920); const savedChatSize = getSavedChatSize(); - const chatWidth = - savedChatSize || Math.floor((pageWidth - sidenavWidth) * 0.6); + const defaultLeftPaneWidth = Math.max(Math.floor(pageWidth / 4), 400); + const chatWidth = savedChatSize || pageWidth - defaultLeftPaneWidth; return Math.max(Math.min(maxChatSize, chatWidth), MIN_CHAT_WIDTH); };