Use call link color in create, update, show

This commit is contained in:
ayumi-signal 2024-06-26 10:35:48 -07:00 committed by GitHub
parent f8af3fcdf6
commit 932e4c3343
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 33 additions and 20 deletions

View file

@ -30,7 +30,7 @@ import {
} from '../types/CallLink';
import type { LocalizerType } from '../types/Util';
import { isTestOrMockEnvironment } from '../environment';
import { AvatarColors } from '../types/Colors';
import { getColorForCallLink } from './getColorForCallLink';
export const CALL_LINK_DEFAULT_STATE = {
name: '',
@ -105,21 +105,6 @@ export function callLinkToConversation(
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(
roomId: string,