signal-desktop/ts/util/migrateColor.ts

54 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-01-07 18:06:09 +00:00
// Copyright 2018-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2021-05-28 16:15:17 +00:00
import { AvatarColorType } from '../types/Colors';
2021-05-28 16:15:17 +00:00
export function migrateColor(color?: string): AvatarColorType {
switch (color) {
// These colors no longer exist
case 'orange':
case 'amber':
2021-05-28 16:15:17 +00:00
return 'vermilion';
case 'yellow':
2021-05-28 16:15:17 +00:00
return 'burlap';
case 'deep_purple':
2021-05-28 16:15:17 +00:00
return 'violet';
case 'light_blue':
return 'blue';
case 'cyan':
return 'teal';
case 'lime':
2021-05-28 16:15:17 +00:00
return 'wintergreen';
2021-05-28 16:15:17 +00:00
// Actual color names
case 'red':
2021-05-28 16:15:17 +00:00
return 'crimson';
case 'deep_orange':
2021-05-28 16:15:17 +00:00
return 'vermilion';
case 'brown':
2021-05-28 16:15:17 +00:00
return 'burlap';
case 'pink':
2021-05-28 16:15:17 +00:00
return 'plum';
case 'purple':
2021-05-28 16:15:17 +00:00
return 'violet';
case 'green':
2021-05-28 16:15:17 +00:00
return 'forest';
case 'light_green':
2021-05-28 16:15:17 +00:00
return 'wintergreen';
case 'blue_grey':
2021-05-28 16:15:17 +00:00
return 'steel';
case 'grey':
2021-05-28 16:15:17 +00:00
return 'steel';
// These can stay as they are
case 'blue':
case 'indigo':
case 'teal':
case 'ultramarine':
return color;
default:
2021-05-28 16:15:17 +00:00
return 'steel';
}
}