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

74 lines
2.4 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, { memo } from 'react';
2023-01-02 21:34:41 +00:00
import { useSelector } from 'react-redux';
import { Inbox } from '../../components/Inbox';
import { getIntl } from '../selectors/user';
import { SmartCustomizingPreferredReactionsModal } from './CustomizingPreferredReactionsModal';
import { getIsCustomizingPreferredReactions } from '../selectors/preferredReactions';
2023-08-09 00:53:06 +00:00
import type { SmartNavTabsProps } from './NavTabs';
import { SmartNavTabs } from './NavTabs';
import { SmartStoriesTab } from './StoriesTab';
import { SmartCallsTab } from './CallsTab';
import { useItemsActions } from '../ducks/items';
import { getNavTabsCollapsed } from '../selectors/items';
import { SmartChatsTab } from './ChatsTab';
import { getHasInitialLoadCompleted } from '../selectors/app';
import {
getInboxEnvelopeTimestamp,
getInboxFirstEnvelopeTimestamp,
} from '../selectors/inbox';
2023-01-02 21:34:41 +00:00
2023-08-09 00:53:06 +00:00
function renderChatsTab() {
return <SmartChatsTab />;
}
function renderCallsTab() {
return <SmartCallsTab />;
2023-01-02 21:34:41 +00:00
}
function renderCustomizingPreferredReactionsModal() {
return <SmartCustomizingPreferredReactionsModal />;
}
2023-08-09 00:53:06 +00:00
function renderNavTabs(props: SmartNavTabsProps) {
return <SmartNavTabs {...props} />;
}
2023-08-09 00:53:06 +00:00
function renderStoriesTab() {
return <SmartStoriesTab />;
2023-01-02 21:34:41 +00:00
}
export const SmartInbox = memo(function SmartInbox(): JSX.Element {
2023-01-02 21:34:41 +00:00
const i18n = useSelector(getIntl);
const isCustomizingPreferredReactions = useSelector(
getIsCustomizingPreferredReactions
);
const envelopeTimestamp = useSelector(getInboxEnvelopeTimestamp);
const firstEnvelopeTimestamp = useSelector(getInboxFirstEnvelopeTimestamp);
const hasInitialLoadCompleted = useSelector(getHasInitialLoadCompleted);
2023-08-09 00:53:06 +00:00
const navTabsCollapsed = useSelector(getNavTabsCollapsed);
2023-08-09 00:53:06 +00:00
const { toggleNavTabsCollapse } = useItemsActions();
2023-01-02 21:34:41 +00:00
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}
2023-08-09 00:53:06 +00:00
navTabsCollapsed={navTabsCollapsed}
onToggleNavTabsCollapse={toggleNavTabsCollapse}
renderChatsTab={renderChatsTab}
renderCallsTab={renderCallsTab}
2023-01-02 21:34:41 +00:00
renderCustomizingPreferredReactionsModal={
renderCustomizingPreferredReactionsModal
}
2023-08-09 00:53:06 +00:00
renderNavTabs={renderNavTabs}
renderStoriesTab={renderStoriesTab}
2023-01-02 21:34:41 +00:00
/>
);
});