Add preliminary message backup harness

This commit is contained in:
Fedor Indutny 2024-03-15 07:20:33 -07:00 committed by GitHub
parent 231bf91a22
commit d85a1d5074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2997 additions and 121 deletions

View file

@ -2,18 +2,28 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { sample } from 'lodash';
import { AvatarColors } from '../types/Colors';
import type { ConversationAttributesType } from '../model-types';
import type { AvatarColorType, CustomColorType } from '../types/Colors';
import type { ServiceIdString } from '../types/ServiceId';
const NEW_COLOR_NAMES = new Set(AvatarColors);
export function migrateColor(color?: string): AvatarColorType {
export function migrateColor(
serviceId?: ServiceIdString,
color?: string
): AvatarColorType {
if (color && NEW_COLOR_NAMES.has(color)) {
return color;
}
return sample(AvatarColors) || AvatarColors[0];
if (!serviceId) {
return sample(AvatarColors) || AvatarColors[0];
}
const index = (parseInt(serviceId.slice(-4), 16) || 0) % AvatarColors.length;
return AvatarColors[index];
}
export function getCustomColorData(conversation: ConversationAttributesType): {