Fixes global chat color setting

This commit is contained in:
Josh Perez 2021-06-02 17:05:09 -04:00 committed by GitHub
parent a6ce00ff37
commit bd46e3afd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 250 additions and 122 deletions

View file

@ -24,6 +24,7 @@ import {
AvatarColorType,
AvatarColors,
ConversationColorType,
CustomColorType,
} from '../types/Colors';
import { MessageModel } from './messages';
import { isMuted } from '../util/isMuted';
@ -1446,6 +1447,8 @@ export class ConversationModel extends window.Backbone
.filter((member): member is ConversationType => member !== null)
: undefined;
const { customColor, customColorId } = this.getCustomColorData();
// TODO: DESKTOP-720
/* eslint-disable @typescript-eslint/no-non-null-assertion */
const result: ConversationType = {
@ -1469,8 +1472,8 @@ export class ConversationModel extends window.Backbone
unblurredAvatarPath: this.getAbsoluteUnblurredAvatarPath(),
color,
conversationColor: this.getConversationColor(),
customColor: this.get('customColor'),
customColorId: this.get('customColorId'),
customColor,
customColorId,
discoveredUnregisteredAt: this.get('discoveredUnregisteredAt'),
draftBodyRanges,
draftPreview,
@ -4871,8 +4874,33 @@ export class ConversationModel extends window.Backbone
}
getConversationColor(): ConversationColorType {
return (this.get('conversationColor') ||
'ultramarine') as ConversationColorType;
const defaultConversationColor = window.storage.get(
'defaultConversationColor'
);
if (defaultConversationColor.customColorData) {
return 'custom';
}
return this.get('conversationColor') || defaultConversationColor.color;
}
getCustomColorData(): {
customColor?: CustomColorType;
customColorId?: string;
} {
const defaultConversationColor = window.storage.get(
'defaultConversationColor'
);
return {
customColor:
this.get('customColor') ||
defaultConversationColor.customColorData?.value,
customColorId:
this.get('customColorId') ||
defaultConversationColor.customColorData?.id,
};
}
private getAvatarPath(): undefined | string {