Backward compatibility fix with SDA 9.2.0 and client 1.5

This commit is contained in:
sbenmoussati 2021-08-05 20:02:16 +02:00
parent f626e997b3
commit fbcae64c74
2 changed files with 17 additions and 4 deletions

View File

@ -169,7 +169,7 @@ export default class NotificationComp extends React.Component<
title={i18n.t('Close')()} title={i18n.t('Close')()}
onClick={this.eventHandlers.onClose(id)} onClick={this.eventHandlers.onClose(id)}
> >
<img src={closeImgFilePath} alt='close' /> <img src={closeImgFilePath} title={i18n.t('Close')()} alt='close' />
</div> </div>
<div <div
className='main-container' className='main-container'
@ -429,10 +429,24 @@ export default class NotificationComp extends React.Component<
*/ */
private updateState(_event, data): void { private updateState(_event, data): void {
const { color } = data; const { color } = data;
data.color = this.isValidColor(color) ? color : ''; // FYI: 1.5 sends hex color but without '#', reason why we check and add prefix if necessary.
// Goal is to keep backward compatibility with 1.5 colors (SDA v. 9.2.0)
const isOldColor = /^([A-Fa-f0-9]{6})/.test(color);
data.color = isOldColor
? `#${color}`
: this.isValidColor(color)
? color
: '';
data.isInputHidden = true; data.isInputHidden = true;
data.containerHeight = CONTAINER_HEIGHT; data.containerHeight = CONTAINER_HEIGHT;
data.theme = data.theme ? data.theme : Themes.LIGHT; // FYI: 1.5 doesn't send current theme. We need to deduce it from the color that is sent.
// Goal is to keep backward compatibility with 1.5 themes (SDA v. 9.2.0)
data.theme =
isOldColor && darkTheme.includes(data.color)
? Themes.DARK
: data.theme
? data.theme
: Themes.LIGHT;
this.resetNotificationData(); this.resetNotificationData();
this.setState(data as INotificationState); this.setState(data as INotificationState);
} }

View File

@ -27,7 +27,6 @@
--notification-border-color: #717681; --notification-border-color: #717681;
--button-color: #b0b3ba; --button-color: #b0b3ba;
--button-border-color: #b0b3ba; --button-border-color: #b0b3ba;
--button-border-color: #717681;
--button-hover-color: #cdcfd4; --button-hover-color: #cdcfd4;
--button-hover-border-color: #cdcfd4; --button-hover-border-color: #cdcfd4;
--button-hover-bg-color: #3a3d43; --button-hover-bg-color: #3a3d43;