Restore useful bubble for incoming messages with errors

This commit is contained in:
Scott Nonnenberg 2022-05-31 09:26:07 -07:00 committed by GitHub
parent 6668348197
commit 6f2b01d98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

View File

@ -7,12 +7,12 @@ import { noop } from 'lodash';
import classNames from 'classnames';
import type { VideoFrameSource } from 'ringrtc';
import type {
ActiveCallStateType,
SetLocalAudioType,
SetLocalPreviewType,
SetLocalVideoType,
SetRendererCanvasType,
} from '../state/ducks/calling';
import { isInSpeakerView } from '../state/selectors/calling';
import { Avatar } from './Avatar';
import { CallingHeader } from './CallingHeader';
import { CallingPreCallInfo, RingMode } from './CallingPreCallInfo';
@ -25,6 +25,7 @@ import type {
} from '../types/Calling';
import {
CallMode,
CallViewMode,
CallState,
GroupCallConnectionState,
GroupCallJoinState,
@ -77,6 +78,15 @@ type DirectCallHeaderMessagePropsType = {
joinedAt?: number;
};
export const isInSpeakerView = (
call: Pick<ActiveCallStateType, 'viewMode'> | undefined
): boolean => {
return Boolean(
call?.viewMode === CallViewMode.Presentation ||
call?.viewMode === CallViewMode.Speaker
);
};
function DirectCallHeaderMessage({
callState,
i18n,

View File

@ -1371,8 +1371,8 @@ export function getMessagePropStatus(
>,
ourConversationId: string | undefined
): LastMessageStatus | undefined {
if (!isOutgoing(message)) {
return undefined;
if (isIncoming(message)) {
return hasErrors(message) ? 'error' : undefined;
}
if (getLastChallengeError(message)) {

View File

@ -351,12 +351,24 @@ describe('state/selectors/messages', () => {
...overrides,
});
it('returns undefined for incoming messages', () => {
it('returns undefined for incoming messages with no errors', () => {
const message = createMessage({ type: 'incoming' });
assert.isUndefined(getMessagePropStatus(message, ourConversationId));
});
it('returns "error" for incoming messages with errors', () => {
const message = createMessage({
type: 'incoming',
errors: [new Error('something went wrong')],
});
assert.strictEqual(
getMessagePropStatus(message, ourConversationId),
'error'
);
});
it('returns "paused" for messages with challenges', () => {
const challengeError: ShallowChallengeError = Object.assign(
new Error('a challenge'),