Update raise hand strings

This commit is contained in:
ayumi-signal 2024-06-10 16:26:49 -07:00 committed by GitHub
parent 0e54740e01
commit 041347e30d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 57 additions and 24 deletions

View file

@ -3563,9 +3563,17 @@
"description": "Shown in a group call lobby when call ringing is enabled, then the user disables ringing using the Ringing toggle button." "description": "Shown in a group call lobby when call ringing is enabled, then the user disables ringing using the Ringing toggle button."
}, },
"icu:CallControls__RaiseHandsToast--you": { "icu:CallControls__RaiseHandsToast--you": {
"messageformat": "Your hand is raised.", "messageformat": "You raised a hand.",
"description": "Shown in a call when the user raises their hand." "description": "Shown in a call when the user raises their hand."
}, },
"icu:CallControls__RaiseHandsToast--you-and-one": {
"messageformat": "You and {otherName} raised a hand.",
"description": "Shown in a call when the user and one other person raise their hands."
},
"icu:CallControls__RaiseHandsToast--you-and-more": {
"messageformat": "You, {otherName}, and {overflowCount, plural, one {#} other {#}} more raised a hand.",
"description": "Shown in a call when the user and 2 or more other persons raise their hands."
},
"icu:CallControls__RaiseHandsToast--one": { "icu:CallControls__RaiseHandsToast--one": {
"messageformat": "{name} raised a hand.", "messageformat": "{name} raised a hand.",
"description": "Shown in a call when someone else raises their hand." "description": "Shown in a call when someone else raises their hand."

View file

@ -3,7 +3,7 @@
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import React, { useState, useRef, useEffect, useCallback } from 'react'; import React, { useState, useRef, useEffect, useCallback } from 'react';
import { isEqual, noop, sortBy } from 'lodash'; import { isEqual, noop } from 'lodash';
import classNames from 'classnames'; import classNames from 'classnames';
import type { VideoFrameSource } from '@signalapp/ringrtc'; import type { VideoFrameSource } from '@signalapp/ringrtc';
import type { import type {
@ -553,24 +553,34 @@ export function CallScreen({
} }
const renderRaisedHandsToast = React.useCallback( const renderRaisedHandsToast = React.useCallback(
(hands: Array<number>) => { (demuxIds: Array<number>) => {
// Sort "You" to the front. const names: Array<string> = [];
const names = sortBy(hands, demuxId => let isYourHandRaised = false;
demuxId === localDemuxId ? 0 : 1 for (const demuxId of demuxIds) {
).map(demuxId => if (demuxId === localDemuxId) {
demuxId === localDemuxId isYourHandRaised = true;
? i18n('icu:you') continue;
: conversationsByDemuxId.get(demuxId)?.title }
);
const handConversation = conversationsByDemuxId.get(demuxId);
if (!handConversation) {
continue;
}
names.push(handConversation.title);
}
const count = names.length;
const name = names[0] ?? '';
const otherName = names[1] ?? '';
let message: string; let message: string;
let buttonOverride: JSX.Element | undefined; let buttonOverride: JSX.Element | undefined;
const count = names.length;
switch (count) { switch (count) {
case 0: case 0:
return undefined; return undefined;
case 1: case 1:
if (names[0] === i18n('icu:you')) { if (isYourHandRaised) {
message = i18n('icu:CallControls__RaiseHandsToast--you'); message = i18n('icu:CallControls__RaiseHandsToast--you');
buttonOverride = ( buttonOverride = (
<button <button
@ -583,22 +593,37 @@ export function CallScreen({
); );
} else { } else {
message = i18n('icu:CallControls__RaiseHandsToast--one', { message = i18n('icu:CallControls__RaiseHandsToast--one', {
name: names[0] ?? '', name,
}); });
} }
break; break;
case 2: case 2:
message = i18n('icu:CallControls__RaiseHandsToast--two', { if (isYourHandRaised) {
name: names[0] ?? '', message = i18n('icu:CallControls__RaiseHandsToast--you-and-one', {
otherName: names[1] ?? '', otherName,
}); });
} else {
message = i18n('icu:CallControls__RaiseHandsToast--two', {
name,
otherName,
});
}
break; break;
default: default: {
message = i18n('icu:CallControls__RaiseHandsToast--more', { const overflowCount = count - 2;
name: names[0] ?? '', if (isYourHandRaised) {
otherName: names[1] ?? '', message = i18n('icu:CallControls__RaiseHandsToast--you-and-more', {
overflowCount: names.length - 2, otherName,
}); overflowCount,
});
} else {
message = i18n('icu:CallControls__RaiseHandsToast--more', {
name: names[0] ?? '',
otherName,
overflowCount,
});
}
}
} }
return ( return (
<div className="CallingRaisedHandsToast__Content"> <div className="CallingRaisedHandsToast__Content">