From 1280afe619b301d60634ddab17590150cd1e102e Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 6 May 2024 14:48:31 -0700 Subject: [PATCH] Show reconnecting notification when screensharing --- _locales/en/messages.json | 12 +++ app/main.ts | 18 +++- ...CallingScreenSharingController.stories.tsx | 12 +++ .../CallingScreenSharingController.tsx | 19 +++- ts/services/calling.ts | 98 ++++++++++++++++++- ts/state/ducks/calling.ts | 43 +++++--- ts/types/Calling.ts | 6 ++ ts/window.d.ts | 3 + ts/windows/screenShare/app.tsx | 35 ++++--- ts/windows/screenShare/preload.ts | 16 +++ 10 files changed, 227 insertions(+), 35 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f85d5d3ab0..fa769ecf95 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1813,10 +1813,22 @@ "messageformat": "Click here to return to the call when you're ready to stop presenting.", "description": "Body text for the share screen notification" }, + "icu:calling__presenting--reconnecting--notification-title": { + "messageformat": "Reconnecting...", + "description": "Title for the share screen reconnecting notification" + }, + "icu:calling__presenting--reconnecting--notification-body": { + "messageformat": "Your connection was lost. Signal is reconnecting.", + "description": "Body text for the share screen reconnecting notification" + }, "icu:calling__presenting--info": { "messageformat": "Signal is sharing {window}.", "description": "Text that appears in the screen sharing controller to inform person that they are presenting" }, + "icu:calling__presenting--reconnecting": { + "messageformat": "Reconnecting...", + "description": "Text that appears in the screen sharing controller to inform person that the call is in reconnecting state" + }, "icu:calling__presenting--stop": { "messageformat": "Stop sharing", "description": "Button for stopping screen sharing" diff --git a/app/main.ts b/app/main.ts index 26d56b4780..e04aae77d3 100644 --- a/app/main.ts +++ b/app/main.ts @@ -113,6 +113,7 @@ import { load as loadLocale } from './locale'; import type { LoggerType } from '../ts/types/Logging'; import { HourCyclePreference } from '../ts/types/I18N'; +import { ScreenShareStatus } from '../ts/types/Calling'; import { DBVersionFromFutureError } from '../ts/sql/migrations'; import type { ParsedSignalRoute } from '../ts/util/signalRoutes'; import { parseSignalRoute } from '../ts/util/signalRoutes'; @@ -2332,11 +2333,20 @@ ipc.on( } ); -ipc.on('close-screen-share-controller', () => { - if (screenShareWindow) { - screenShareWindow.close(); +ipc.on( + 'screen-share:status-change', + (_event: Electron.Event, status: ScreenShareStatus) => { + if (!screenShareWindow) { + return; + } + + if (status === ScreenShareStatus.Disconnected) { + screenShareWindow.close(); + } else { + screenShareWindow.webContents.send('status-change', status); + } } -}); +); ipc.on('stop-screen-share', () => { if (mainWindow) { diff --git a/ts/components/CallingScreenSharingController.stories.tsx b/ts/components/CallingScreenSharingController.stories.tsx index 08a1c30430..d55fba16f3 100644 --- a/ts/components/CallingScreenSharingController.stories.tsx +++ b/ts/components/CallingScreenSharingController.stories.tsx @@ -9,6 +9,7 @@ import type { PropsType } from './CallingScreenSharingController'; import { CallingScreenSharingController } from './CallingScreenSharingController'; import { setupI18n } from '../util/setupI18n'; +import { ScreenShareStatus } from '../types/Calling'; import enMessages from '../../_locales/en/messages.json'; const i18n = setupI18n('en', enMessages); @@ -18,6 +19,7 @@ const createProps = (overrideProps: Partial = {}): PropsType => ({ onCloseController: action('on-close-controller'), onStopSharing: action('on-stop-sharing'), presentedSourceName: overrideProps.presentedSourceName || 'Application', + status: overrideProps.status || ScreenShareStatus.Connected, }); export default { @@ -38,3 +40,13 @@ export function ReallyLongAppName(): JSX.Element { /> ); } + +export function Reconnecting(): JSX.Element { + return ( + + ); +} diff --git a/ts/components/CallingScreenSharingController.tsx b/ts/components/CallingScreenSharingController.tsx index 3eeef2e190..b4ad518dc6 100644 --- a/ts/components/CallingScreenSharingController.tsx +++ b/ts/components/CallingScreenSharingController.tsx @@ -4,11 +4,13 @@ import React from 'react'; import { Button, ButtonVariant } from './Button'; import type { LocalizerType } from '../types/Util'; +import { ScreenShareStatus } from '../types/Calling'; export type PropsType = { i18n: LocalizerType; onCloseController: () => unknown; onStopSharing: () => unknown; + status: ScreenShareStatus; presentedSourceName: string; }; @@ -16,15 +18,22 @@ export function CallingScreenSharingController({ i18n, onCloseController, onStopSharing, + status, presentedSourceName, }: PropsType): JSX.Element { + let text: string; + + if (status === ScreenShareStatus.Reconnecting) { + text = i18n('icu:calling__presenting--reconnecting'); + } else { + text = i18n('icu:calling__presenting--info', { + window: presentedSourceName, + }); + } + return (
-
- {i18n('icu:calling__presenting--info', { - window: presentedSourceName, - })} -
+
{text}