diff --git a/ts/components/ChatsTab.tsx b/ts/components/ChatsTab.tsx
index e2af2b51251..9a464421b5a 100644
--- a/ts/components/ChatsTab.tsx
+++ b/ts/components/ChatsTab.tsx
@@ -6,6 +6,7 @@ import type { LocalizerType } from '../types/I18N';
import type { NavTabPanelProps } from './NavTabs';
import { WhatsNewLink } from './WhatsNewLink';
import type { UnreadStats } from '../util/countUnreadStats';
+import type { SmartConversationViewProps } from '../state/smart/ConversationView';
export type ChatsTabProps = Readonly<{
otherTabsUnreadStats: UnreadStats;
@@ -15,7 +16,7 @@ export type ChatsTabProps = Readonly<{
hasFailedStorySends: boolean;
navTabsCollapsed: boolean;
onToggleNavTabsCollapse: (navTabsCollapsed: boolean) => void;
- renderConversationView: () => JSX.Element;
+ renderConversationView: (props: SmartConversationViewProps) => JSX.Element;
renderLeftPane: (props: NavTabPanelProps) => JSX.Element;
renderMiniPlayer: (options: { shouldFlow: boolean }) => JSX.Element;
selectedConversationId: string | undefined;
@@ -51,10 +52,12 @@ export function ChatsTab({
{selectedConversationId ? (
- {renderConversationView()}
+ {renderConversationView({ selectedConversationId })}
) : (
diff --git a/ts/state/smart/ChatsTab.tsx b/ts/state/smart/ChatsTab.tsx
index 5584d9d4a59..c190b0a1066 100644
--- a/ts/state/smart/ChatsTab.tsx
+++ b/ts/state/smart/ChatsTab.tsx
@@ -3,6 +3,7 @@
import React, { memo, useEffect, useRef } from 'react';
import { useSelector } from 'react-redux';
import { ChatsTab } from '../../components/ChatsTab';
+import type { SmartConversationViewProps } from './ConversationView';
import { SmartConversationView } from './ConversationView';
import { SmartMiniPlayer } from './MiniPlayer';
import { SmartLeftPane } from './LeftPane';
@@ -27,8 +28,8 @@ import {
getTargetedMessageSource,
} from '../selectors/conversations';
-function renderConversationView() {
- return ;
+function renderConversationView(props: SmartConversationViewProps) {
+ return ;
}
function renderLeftPane(props: NavTabPanelProps) {
diff --git a/ts/state/smart/ConversationView.tsx b/ts/state/smart/ConversationView.tsx
index 4109dc6fb4c..f1a3e31e6f4 100644
--- a/ts/state/smart/ConversationView.tsx
+++ b/ts/state/smart/ConversationView.tsx
@@ -11,7 +11,6 @@ import { SmartTimeline } from './Timeline';
import {
getActivePanel,
getIsPanelAnimating,
- getSelectedConversationId,
getSelectedMessageIds,
} from '../selectors/conversations';
import { useComposerActions } from '../ducks/composer';
@@ -34,43 +33,41 @@ function renderPanel(conversationId: string) {
return ;
}
-export const SmartConversationView = memo(
- function SmartConversationView(): JSX.Element {
- const conversationId = useSelector(getSelectedConversationId);
+export type SmartConversationViewProps = Readonly<{
+ selectedConversationId: string;
+}>;
- if (!conversationId) {
- throw new Error('SmartConversationView: No selected conversation');
- }
+export const SmartConversationView = memo(function SmartConversationView(
+ props: SmartConversationViewProps
+): JSX.Element {
+ const { toggleSelectMode } = useConversationsActions();
+ const selectedMessageIds = useSelector(getSelectedMessageIds);
+ const isSelectMode = selectedMessageIds != null;
- const { toggleSelectMode } = useConversationsActions();
- const selectedMessageIds = useSelector(getSelectedMessageIds);
- const isSelectMode = selectedMessageIds != null;
+ const { processAttachments } = useComposerActions();
- const { processAttachments } = useComposerActions();
+ const hasOpenModal = useSelector(isShowingAnyModal);
+ const activePanel = useSelector(getActivePanel);
+ const isPanelAnimating = useSelector(getIsPanelAnimating);
+ const shouldHideConversationView = activePanel && !isPanelAnimating;
- const hasOpenModal = useSelector(isShowingAnyModal);
- const activePanel = useSelector(getActivePanel);
- const isPanelAnimating = useSelector(getIsPanelAnimating);
- const shouldHideConversationView = activePanel && !isPanelAnimating;
+ const onExitSelectMode = useCallback(() => {
+ toggleSelectMode(false);
+ }, [toggleSelectMode]);
- const onExitSelectMode = useCallback(() => {
- toggleSelectMode(false);
- }, [toggleSelectMode]);
-
- return (
-
- );
- }
-);
+ return (
+
+ );
+});