Skip to content

Commit

Permalink
Group Calling: blocking participants
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Hahn <evanhahn@signal.org>
  • Loading branch information
josh-signal and EvanHahn-Signal committed Dec 2, 2020
1 parent f3f2cb2 commit 81cc8a1
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 20 deletions.
16 changes: 15 additions & 1 deletion _locales/en/messages.json
Expand Up @@ -1031,7 +1031,7 @@
"description": "Label for back button in a conversation"
},
"moreInfo": {
"message": "More Info...",
"message": "More Info",
"description": "Shown on the drop-down menu for an individual message, takes you to message detail screen"
},
"retrySend": {
Expand Down Expand Up @@ -1280,6 +1280,20 @@
}
}
},
"calling__you-have-blocked": {
"message": "You have blocked $name$",
"description": "when you block someone and cannot view their video",
"placeholders": {
"name": {
"content": "$1",
"example": "Henry Richard"
}
}
},
"calling__block-info": {
"message": "You won't receive their audio or video and they won't receive yours.",
"description": "Shown in the modal dialog to describe how blocking works in a gorup call"
},
"alwaysRelayCallsDescription": {
"message": "Always relay calls",
"description": "Description of the always relay calls setting"
Expand Down
1 change: 1 addition & 0 deletions images/icons/v2/block-24.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions stylesheets/_modules.scss
Expand Up @@ -6301,6 +6301,30 @@ button.module-image__border-overlay:focus {
background-color: $color-gray-75;
}

&__blocked {
@include color-svg('../images/icons/v2/block-24.svg', $color-white);
height: 24px;
margin-bottom: 16px;
width: 24px;

&--info {
@include button-reset;
background-color: $color-gray-75;
border-radius: 16px;
color: $color-white;
line-height: 16px;
padding: 3px 10px;
}

&--modal-title {
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
}
}

&--title {
@include font-caption;
background: linear-gradient(
Expand Down
5 changes: 5 additions & 0 deletions ts/components/CallScreen.stories.tsx
Expand Up @@ -191,6 +191,7 @@ story.add('Group call - 1', () => (
demuxId: 0,
hasRemoteAudio: true,
hasRemoteVideo: true,
isBlocked: false,
isSelf: false,
title: 'Tyler',
videoAspectRatio: 1.3,
Expand All @@ -209,6 +210,7 @@ story.add('Group call - Many', () => (
demuxId: 0,
hasRemoteAudio: true,
hasRemoteVideo: true,
isBlocked: false,
isSelf: false,
title: 'Amy',
videoAspectRatio: 1.3,
Expand All @@ -217,6 +219,7 @@ story.add('Group call - Many', () => (
demuxId: 1,
hasRemoteAudio: true,
hasRemoteVideo: true,
isBlocked: false,
isSelf: true,
title: 'Bob',
videoAspectRatio: 1.3,
Expand All @@ -225,6 +228,7 @@ story.add('Group call - Many', () => (
demuxId: 2,
hasRemoteAudio: true,
hasRemoteVideo: true,
isBlocked: true,
isSelf: false,
title: 'Alice',
videoAspectRatio: 1.3,
Expand All @@ -246,6 +250,7 @@ story.add('Group call - reconnecting', () => (
demuxId: 0,
hasRemoteAudio: true,
hasRemoteVideo: true,
isBlocked: false,
isSelf: false,
title: 'Tyler',
videoAspectRatio: 1.3,
Expand Down
1 change: 1 addition & 0 deletions ts/components/CallingParticipantsList.stories.tsx
Expand Up @@ -23,6 +23,7 @@ function createParticipant(
demuxId: 2,
hasRemoteAudio: Boolean(participantProps.hasRemoteAudio),
hasRemoteVideo: Boolean(participantProps.hasRemoteVideo),
isBlocked: Boolean(participantProps.isBlocked),
isSelf: Boolean(participantProps.isSelf),
name: participantProps.name,
profileName: participantProps.title,
Expand Down
21 changes: 20 additions & 1 deletion ts/components/GroupCallRemoteParticipant.stories.tsx
Expand Up @@ -15,14 +15,18 @@ import enMessages from '../../_locales/en/messages.json';
const i18n = setupI18n('en', enMessages);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const createProps = (overrideProps: Partial<PropsType> = {}): any => ({
const createProps = (
overrideProps: Partial<PropsType> = {},
isBlocked?: boolean
): any => ({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getGroupCallVideoFrameSource: noop as any,
i18n,
remoteParticipant: {
demuxId: 123,
hasRemoteAudio: false,
hasRemoteVideo: true,
isBlocked: Boolean(isBlocked),
isSelf: false,
title:
'Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santísima Trinidad Ruiz y Picasso',
Expand Down Expand Up @@ -52,3 +56,18 @@ story.add('isInPip', () => (
})}
/>
));

story.add('Blocked', () => (
<GroupCallRemoteParticipant
{...createProps(
{
isInPip: false,
height: 120,
left: 0,
top: 0,
width: 120,
},
true
)}
/>
));
88 changes: 73 additions & 15 deletions ts/components/GroupCallRemoteParticipant.tsx
Expand Up @@ -18,6 +18,8 @@ import {
import { LocalizerType } from '../types/Util';
import { CallBackgroundBlur } from './CallBackgroundBlur';
import { Avatar, AvatarSize } from './Avatar';
import { ConfirmationModal } from './ConfirmationModal';
import { Intl } from './Intl';
import { ContactName } from './conversation/ContactName';

// The max size video frame we'll support (in RGBA)
Expand Down Expand Up @@ -45,20 +47,22 @@ export type PropsType = BasePropsType & (InPipPropsType | NotInPipPropsType);

export const GroupCallRemoteParticipant: React.FC<PropsType> = React.memo(
props => {
const { getGroupCallVideoFrameSource } = props;
const { getGroupCallVideoFrameSource, i18n } = props;

const {
avatarPath,
color,
profileName,
title,
demuxId,
hasRemoteAudio,
hasRemoteVideo,
isBlocked,
profileName,
title,
} = props.remoteParticipant;

const [isWide, setIsWide] = useState(true);
const [hasHover, setHover] = useState(false);
const [showBlockInfo, setShowBlockInfo] = useState(false);

const remoteVideoRef = useRef<HTMLCanvasElement | null>(null);
const canvasContextRef = useRef<CanvasRenderingContext2D | null>(null);
Expand Down Expand Up @@ -173,6 +177,45 @@ export const GroupCallRemoteParticipant: React.FC<PropsType> = React.memo(
}

const showHover = hasHover && !props.isInPip;
const canShowVideo = hasRemoteVideo && !isBlocked;

if (showBlockInfo) {
return (
<ConfirmationModal
i18n={i18n}
onClose={() => {
setShowBlockInfo(false);
}}
title={
<div className="module-ongoing-call__group-call-remote-participant__blocked--modal-title">
<Intl
i18n={i18n}
id="calling__you-have-blocked"
components={[
<ContactName
key="name"
profileName={profileName}
title={title}
i18n={i18n}
/>,
]}
/>
</div>
}
actions={[
{
text: i18n('ok'),
action: () => {
setShowBlockInfo(false);
},
style: 'affirmative',
},
]}
>
{i18n('calling__block-info')}
</ConfirmationModal>
);
}

return (
<div
Expand All @@ -194,11 +237,11 @@ export const GroupCallRemoteParticipant: React.FC<PropsType> = React.memo(
module="module-ongoing-call__group-call-remote-participant--contact-name"
profileName={profileName}
title={title}
i18n={props.i18n}
i18n={i18n}
/>
</div>
)}
{hasRemoteVideo ? (
{canShowVideo ? (
<canvas
className="module-ongoing-call__group-call-remote-participant__remote-video"
style={canvasStyles}
Expand All @@ -217,16 +260,31 @@ export const GroupCallRemoteParticipant: React.FC<PropsType> = React.memo(
/>
) : (
<CallBackgroundBlur avatarPath={avatarPath} color={color}>
<Avatar
avatarPath={avatarPath}
color={color || 'ultramarine'}
noteToSelf={false}
conversationType="direct"
i18n={props.i18n}
profileName={profileName}
title={title}
size={avatarSize}
/>
{isBlocked ? (
<>
<i className="module-ongoing-call__group-call-remote-participant__blocked" />
<button
type="button"
className="module-ongoing-call__group-call-remote-participant__blocked--info"
onClick={() => {
setShowBlockInfo(true);
}}
>
{i18n('moreInfo')}
</button>
</>
) : (
<Avatar
avatarPath={avatarPath}
color={color || 'ultramarine'}
noteToSelf={false}
conversationType="direct"
i18n={i18n}
profileName={profileName}
title={title}
size={avatarSize}
/>
)}
</CallBackgroundBlur>
)}
</div>
Expand Down
3 changes: 3 additions & 0 deletions ts/state/smart/CallManager.tsx
Expand Up @@ -99,6 +99,7 @@ const mapStateToActiveCallProp = (state: StateType) => {
firstName: remoteConversation.firstName,
hasRemoteAudio: remoteParticipant.hasRemoteAudio,
hasRemoteVideo: remoteParticipant.hasRemoteVideo,
isBlocked: Boolean(remoteConversation.isBlocked),
isSelf: remoteParticipant.isSelf,
name: remoteConversation.name,
profileName: remoteConversation.profileName,
Expand All @@ -108,6 +109,8 @@ const mapStateToActiveCallProp = (state: StateType) => {
});
}
);

groupCallParticipants.sort((a, b) => a.title.localeCompare(b.title));
}

return {
Expand Down
1 change: 1 addition & 0 deletions ts/types/Calling.ts
Expand Up @@ -75,6 +75,7 @@ export interface GroupCallRemoteParticipantType {
firstName?: string;
hasRemoteAudio: boolean;
hasRemoteVideo: boolean;
isBlocked: boolean;
isSelf: boolean;
name?: string;
profileName?: string;
Expand Down
6 changes: 3 additions & 3 deletions ts/util/lint/exceptions.json
Expand Up @@ -14562,7 +14562,7 @@
"rule": "React-useRef",
"path": "ts/components/GroupCallRemoteParticipant.js",
"line": " const remoteVideoRef = react_1.useRef(null);",
"lineNumber": 28,
"lineNumber": 31,
"reasonCategory": "usageTrusted",
"updated": "2020-11-11T21:56:04.179Z",
"reasonDetail": "Needed to render the remote video element."
Expand All @@ -14571,7 +14571,7 @@
"rule": "React-useRef",
"path": "ts/components/GroupCallRemoteParticipant.js",
"line": " const canvasContextRef = react_1.useRef(null);",
"lineNumber": 29,
"lineNumber": 32,
"reasonCategory": "usageTrusted",
"updated": "2020-11-17T23:29:38.698Z",
"reasonDetail": "Doesn't touch the DOM."
Expand All @@ -14580,7 +14580,7 @@
"rule": "React-useRef",
"path": "ts/components/GroupCallRemoteParticipant.js",
"line": " const frameBufferRef = react_1.useRef(new ArrayBuffer(FRAME_BUFFER_SIZE));",
"lineNumber": 30,
"lineNumber": 33,
"reasonCategory": "usageTrusted",
"updated": "2020-11-17T16:24:25.480Z",
"reasonDetail": "Doesn't touch the DOM."
Expand Down

0 comments on commit 81cc8a1

Please sign in to comment.