Skip to content

Commit

Permalink
change logic of default chat size generation
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Sep 13, 2023
1 parent 56f26db commit 6c750c6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/pages/commonFeed/CommonFeedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand Down
3 changes: 1 addition & 2 deletions src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export interface FeedLayoutOuterStyles {

export interface FeedLayoutSettings {
withDesktopChatTitle?: boolean;
sidenavWidth?: number;
getSplitViewMaxSize?: (width: number) => number;
}

Expand Down Expand Up @@ -219,7 +218,7 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
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<string | null>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit 6c750c6

Please sign in to comment.