Calls Tab: Show proper color in all default avatars
This commit is contained in:
parent
fc08e70c0f
commit
ce012823af
2 changed files with 19 additions and 1 deletions
|
@ -790,6 +790,7 @@ export function CallsList({
|
||||||
<Avatar
|
<Avatar
|
||||||
acceptedMessageRequest
|
acceptedMessageRequest
|
||||||
avatarPath={conversation.avatarPath}
|
avatarPath={conversation.avatarPath}
|
||||||
|
color={conversation.color}
|
||||||
conversationType={conversation.type}
|
conversationType={conversation.type}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
isMe={false}
|
isMe={false}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import {
|
||||||
} from '../types/CallLink';
|
} from '../types/CallLink';
|
||||||
import type { LocalizerType } from '../types/Util';
|
import type { LocalizerType } from '../types/Util';
|
||||||
import { isTestOrMockEnvironment } from '../environment';
|
import { isTestOrMockEnvironment } from '../environment';
|
||||||
|
import { AvatarColors } from '../types/Colors';
|
||||||
|
|
||||||
export const CALL_LINK_DEFAULT_STATE = {
|
export const CALL_LINK_DEFAULT_STATE = {
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -92,10 +93,11 @@ export function callLinkToConversation(
|
||||||
callLink: CallLinkType,
|
callLink: CallLinkType,
|
||||||
i18n: LocalizerType
|
i18n: LocalizerType
|
||||||
): CallLinkConversationType {
|
): CallLinkConversationType {
|
||||||
const { roomId, name } = callLink;
|
const { roomId, name, rootKey } = callLink;
|
||||||
return {
|
return {
|
||||||
id: roomId,
|
id: roomId,
|
||||||
type: 'callLink',
|
type: 'callLink',
|
||||||
|
color: getColorForCallLink(rootKey),
|
||||||
isMe: false,
|
isMe: false,
|
||||||
title: name || i18n('icu:calling__call-link-default-title'),
|
title: name || i18n('icu:calling__call-link-default-title'),
|
||||||
sharedGroupNames: [],
|
sharedGroupNames: [],
|
||||||
|
@ -103,6 +105,21 @@ export function callLinkToConversation(
|
||||||
badges: [],
|
badges: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// See https://github.com/signalapp/ringrtc/blob/49b4b8a16f997c7fa9a429e96aa83f80b2065c63/src/rust/src/lite/call_links/base16.rs#L8
|
||||||
|
const BASE_16_CONSONANT_ALPHABET = 'bcdfghkmnpqrstxz';
|
||||||
|
|
||||||
|
// See https://github.com/signalapp/ringrtc/blob/49b4b8a16f997c7fa9a429e96aa83f80b2065c63/src/rust/src/lite/call_links/base16.rs#L127-L139
|
||||||
|
export function getColorForCallLink(rootKey: string): string {
|
||||||
|
const rootKeyStart = rootKey.slice(0, 2);
|
||||||
|
|
||||||
|
const upper = BASE_16_CONSONANT_ALPHABET.indexOf(rootKeyStart[0]) || 0 * 16;
|
||||||
|
const lower = BASE_16_CONSONANT_ALPHABET.indexOf(rootKeyStart[1]) || 0;
|
||||||
|
const firstByte = upper + lower;
|
||||||
|
|
||||||
|
const index = firstByte % 12;
|
||||||
|
|
||||||
|
return AvatarColors[index];
|
||||||
|
}
|
||||||
|
|
||||||
export function getPlaceholderCallLinkConversation(
|
export function getPlaceholderCallLinkConversation(
|
||||||
roomId: string,
|
roomId: string,
|
||||||
|
|
Loading…
Reference in a new issue