mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
16 lines
419 B
TypeScript
16 lines
419 B
TypeScript
// Copyright 2018-2021 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import { sample } from 'lodash';
|
|
import { AvatarColors, AvatarColorType } from '../types/Colors';
|
|
|
|
const NEW_COLOR_NAMES = new Set(AvatarColors);
|
|
|
|
export function migrateColor(color?: string): AvatarColorType {
|
|
if (color && NEW_COLOR_NAMES.has(color)) {
|
|
return color;
|
|
}
|
|
|
|
return sample(AvatarColors) || AvatarColors[0];
|
|
}
|