signal-desktop/ts/state/smart/Inbox.tsx

85 lines
3 KiB
TypeScript
Raw Normal View History

2023-01-02 21:34:41 +00:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { useSelector } from 'react-redux';
import type { AppStateType } from '../ducks/app';
import type { ConversationsStateType } from '../ducks/conversations';
import type { StateType } from '../reducer';
import { Inbox } from '../../components/Inbox';
import { getIntl } from '../selectors/user';
import { SmartConversationView } from './ConversationView';
import { SmartCustomizingPreferredReactionsModal } from './CustomizingPreferredReactionsModal';
import { SmartLeftPane } from './LeftPane';
import { useConversationsActions } from '../ducks/conversations';
import { useGlobalModalActions } from '../ducks/globalModals';
import { getIsCustomizingPreferredReactions } from '../selectors/preferredReactions';
import { SmartMiniPlayer } from './MiniPlayer';
2023-01-02 21:34:41 +00:00
function renderConversationView() {
return <SmartConversationView />;
}
function renderCustomizingPreferredReactionsModal() {
return <SmartCustomizingPreferredReactionsModal />;
}
function renderMiniPlayer(options: { shouldFlow: boolean }) {
return <SmartMiniPlayer {...options} />;
}
2023-01-02 21:34:41 +00:00
function renderLeftPane() {
return <SmartLeftPane />;
}
export function SmartInbox(): JSX.Element {
const i18n = useSelector(getIntl);
const isCustomizingPreferredReactions = useSelector(
getIsCustomizingPreferredReactions
);
2023-03-28 20:31:24 +00:00
const envelopeTimestamp = useSelector<StateType, number | undefined>(
state => state.inbox.envelopeTimestamp
);
const firstEnvelopeTimestamp = useSelector<StateType, number | undefined>(
state => state.inbox.firstEnvelopeTimestamp
);
2023-01-02 21:34:41 +00:00
const { hasInitialLoadCompleted } = useSelector<StateType, AppStateType>(
state => state.app
);
2023-03-20 22:23:53 +00:00
const { selectedConversationId, targetedMessage, targetedMessageSource } =
2023-01-02 21:34:41 +00:00
useSelector<StateType, ConversationsStateType>(
state => state.conversations
);
const {
onConversationClosed,
onConversationOpened,
scrollToMessage,
showConversation,
} = useConversationsActions();
const { showWhatsNewModal } = useGlobalModalActions();
return (
<Inbox
2023-03-28 20:31:24 +00:00
envelopeTimestamp={envelopeTimestamp}
firstEnvelopeTimestamp={firstEnvelopeTimestamp}
2023-01-02 21:34:41 +00:00
hasInitialLoadCompleted={hasInitialLoadCompleted}
i18n={i18n}
isCustomizingPreferredReactions={isCustomizingPreferredReactions}
onConversationClosed={onConversationClosed}
onConversationOpened={onConversationOpened}
renderConversationView={renderConversationView}
renderCustomizingPreferredReactionsModal={
renderCustomizingPreferredReactionsModal
}
renderLeftPane={renderLeftPane}
renderMiniPlayer={renderMiniPlayer}
2023-01-02 21:34:41 +00:00
scrollToMessage={scrollToMessage}
selectedConversationId={selectedConversationId}
2023-03-20 22:23:53 +00:00
targetedMessage={targetedMessage}
targetedMessageSource={targetedMessageSource}
2023-01-02 21:34:41 +00:00
showConversation={showConversation}
showWhatsNewModal={showWhatsNewModal}
/>
);
}