2023-01-03 11:55:46 -08:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-06-17 17:15:09 -04:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 13:44:13 -07:00
|
|
|
import React, { memo } from 'react';
|
2024-01-29 12:09:54 -08:00
|
|
|
import { useSelector } from 'react-redux';
|
2023-08-29 02:41:32 +02:00
|
|
|
import type { VerificationTransport } from '../../types/VerificationTransport';
|
2021-08-31 15:58:39 -05:00
|
|
|
import { App } from '../../components/App';
|
2023-04-20 17:23:19 -04:00
|
|
|
import OS from '../../util/os/osMain';
|
2023-08-29 02:41:32 +02:00
|
|
|
import { strictAssert } from '../../util/assert';
|
2021-06-17 17:15:09 -04:00
|
|
|
import { SmartCallManager } from './CallManager';
|
|
|
|
import { SmartGlobalModalContainer } from './GlobalModalContainer';
|
2022-12-09 21:02:22 -05:00
|
|
|
import { SmartLightbox } from './Lightbox';
|
2022-07-06 15:06:20 -04:00
|
|
|
import { SmartStoryViewer } from './StoryViewer';
|
2022-06-08 15:00:32 -07:00
|
|
|
import {
|
|
|
|
getTheme,
|
|
|
|
getIsMainWindowMaximized,
|
|
|
|
getIsMainWindowFullScreen,
|
|
|
|
} from '../selectors/user';
|
2023-08-08 17:53:06 -07:00
|
|
|
import { hasSelectedStoryData } from '../selectors/stories';
|
2024-01-29 12:09:54 -08:00
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import { useAppActions } from '../ducks/app';
|
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
|
|
|
import { useStoriesActions } from '../ducks/stories';
|
2022-07-28 20:10:07 -04:00
|
|
|
import { ErrorBoundary } from '../../components/ErrorBoundary';
|
2022-10-17 10:58:49 -06:00
|
|
|
import { ModalContainer } from '../../components/ModalContainer';
|
2023-01-02 16:34:41 -05:00
|
|
|
import { SmartInbox } from './Inbox';
|
|
|
|
|
|
|
|
function renderInbox(): JSX.Element {
|
|
|
|
return <SmartInbox />;
|
|
|
|
}
|
2021-06-17 17:15:09 -04:00
|
|
|
|
2024-03-13 13:44:13 -07:00
|
|
|
export const SmartApp = memo(function SmartApp() {
|
2024-01-29 12:09:54 -08:00
|
|
|
const app = useSelector((state: StateType) => state.app);
|
2022-07-28 20:10:07 -04:00
|
|
|
|
2024-01-29 12:09:54 -08:00
|
|
|
const { openInbox } = useAppActions();
|
|
|
|
const { scrollToMessage } = useConversationsActions();
|
|
|
|
const { viewStory } = useStoriesActions();
|
2021-06-17 17:15:09 -04:00
|
|
|
|
2024-01-29 12:09:54 -08:00
|
|
|
return (
|
|
|
|
<App
|
|
|
|
{...app}
|
|
|
|
isMaximized={useSelector(getIsMainWindowMaximized)}
|
|
|
|
isFullScreen={useSelector(getIsMainWindowFullScreen)}
|
|
|
|
osClassName={OS.getClassName()}
|
|
|
|
renderCallManager={() => (
|
|
|
|
<ModalContainer className="module-calling__modal-container">
|
|
|
|
<SmartCallManager />
|
|
|
|
</ModalContainer>
|
|
|
|
)}
|
|
|
|
renderGlobalModalContainer={() => <SmartGlobalModalContainer />}
|
|
|
|
renderLightbox={() => <SmartLightbox />}
|
|
|
|
hasSelectedStoryData={useSelector(hasSelectedStoryData)}
|
|
|
|
renderStoryViewer={(closeView: () => unknown) => (
|
|
|
|
<ErrorBoundary name="App/renderStoryViewer" closeView={closeView}>
|
|
|
|
<SmartStoryViewer />
|
|
|
|
</ErrorBoundary>
|
|
|
|
)}
|
|
|
|
renderInbox={renderInbox}
|
|
|
|
requestVerification={(
|
|
|
|
number: string,
|
|
|
|
captcha: string,
|
|
|
|
transport: VerificationTransport
|
|
|
|
): Promise<{ sessionId: string }> => {
|
|
|
|
const { server } = window.textsecure;
|
|
|
|
strictAssert(server !== undefined, 'WebAPI not available');
|
2021-06-17 17:15:09 -04:00
|
|
|
|
2024-01-29 12:09:54 -08:00
|
|
|
return server.requestVerification(number, captcha, transport);
|
|
|
|
}}
|
|
|
|
registerSingleDevice={(
|
|
|
|
number: string,
|
|
|
|
code: string,
|
|
|
|
sessionId: string
|
|
|
|
): Promise<void> => {
|
|
|
|
return window
|
|
|
|
.getAccountManager()
|
|
|
|
.registerSingleDevice(number, code, sessionId);
|
|
|
|
}}
|
|
|
|
theme={useSelector(getTheme)}
|
|
|
|
openInbox={openInbox}
|
|
|
|
scrollToMessage={scrollToMessage}
|
|
|
|
viewStory={viewStory}
|
|
|
|
/>
|
|
|
|
);
|
2024-03-13 13:44:13 -07:00
|
|
|
});
|