Skip to content

Commit

Permalink
Show toast when group call is reconnecting
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Dec 1, 2020
1 parent 2b8ae41 commit 4c78a6c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
21 changes: 21 additions & 0 deletions stylesheets/_modules.scss
Expand Up @@ -6410,6 +6410,27 @@ button.module-image__border-overlay:focus {
fill-mode: forwards;
}
}

&__toast {
@include font-body-1-bold;
background-color: $color-gray-75;
border-radius: 8px;
color: $color-white;
max-width: 80%;
opacity: 1;
padding: 12px;
position: absolute;
text-align: center;
top: 12px;
transition: top 200ms ease-out, opacity 200ms ease-out;
user-select: none;
z-index: 1;

&--hidden {
opacity: 0;
top: 5px;
}
}
}

.module-calling-tools {
Expand Down
23 changes: 22 additions & 1 deletion ts/components/CallScreen.stories.tsx
Expand Up @@ -80,7 +80,7 @@ const createProps = (
hasLocalVideo: true,
pip: false,
settingsDialogOpen: false,
showParticipantsList: true,
showParticipantsList: false,
},
call: overrideProps.callTypeState || getDirectCallState(overrideProps),
conversation: {
Expand Down Expand Up @@ -233,3 +233,24 @@ story.add('Group call - Many', () => (
})}
/>
));

story.add('Group call - reconnecting', () => (
<CallScreen
{...createProps({
callTypeState: {
...getGroupCallState(),
connectionState: GroupCallConnectionState.Reconnecting,
},
groupCallParticipants: [
{
demuxId: 0,
hasRemoteAudio: true,
hasRemoteVideo: true,
isSelf: false,
title: 'Tyler',
videoAspectRatio: 1.3,
},
],
})}
/>
));
7 changes: 7 additions & 0 deletions ts/components/CallScreen.tsx
Expand Up @@ -27,6 +27,7 @@ import { LocalizerType } from '../types/Util';
import { missingCaseError } from '../util/missingCaseError';
import { DirectCallRemoteParticipant } from './DirectCallRemoteParticipant';
import { GroupCallRemoteParticipants } from './GroupCallRemoteParticipants';
import { GroupCallToastManager } from './GroupCallToastManager';

export type PropsType = {
activeCall: ActiveCallType;
Expand Down Expand Up @@ -224,6 +225,12 @@ export const CallScreen: React.FC<PropsType> = ({
}}
role="group"
>
{call.callMode === CallMode.Group ? (
<GroupCallToastManager
connectionState={call.connectionState}
i18n={i18n}
/>
) : null}
<div
className={classNames('module-ongoing-call__header', controlsFadeClass)}
>
Expand Down
37 changes: 37 additions & 0 deletions ts/components/GroupCallToastManager.tsx
@@ -0,0 +1,37 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

import React, { useState, useEffect } from 'react';
import classNames from 'classnames';
import { GroupCallConnectionState } from '../types/Calling';
import { LocalizerType } from '../types/Util';

interface PropsType {
connectionState: GroupCallConnectionState;
i18n: LocalizerType;
}

// In the future, this component should show toasts when users join or leave. See
// DESKTOP-902.
export const GroupCallToastManager: React.FC<PropsType> = ({
connectionState,
i18n,
}) => {
const [isVisible, setIsVisible] = useState(false);

useEffect(() => {
setIsVisible(connectionState === GroupCallConnectionState.Reconnecting);
}, [connectionState, setIsVisible]);

const message = i18n('callReconnecting');

return (
<div
className={classNames('module-ongoing-call__toast', {
'module-ongoing-call__toast--hidden': !isVisible,
})}
>
{message}
</div>
);
};
2 changes: 1 addition & 1 deletion ts/util/lint/exceptions.json
Expand Up @@ -14382,7 +14382,7 @@
"rule": "React-useRef",
"path": "ts/components/CallScreen.js",
"line": " const localVideoRef = react_1.useRef(null);",
"lineNumber": 40,
"lineNumber": 41,
"reasonCategory": "usageTrusted",
"updated": "2020-10-26T21:35:52.858Z",
"reasonDetail": "Used to get the local video element for rendering."
Expand Down

0 comments on commit 4c78a6c

Please sign in to comment.