Skip to content

Commit

Permalink
fix(FEC-10844): advanced caption settings custom caption is always ma…
Browse files Browse the repository at this point in the history
…rked even when choose sample (#570)

Issue: we use isEqual method which makes a class property check.
Solution: use the textStyle isEqual API instead.
  • Loading branch information
Yuvalke committed Dec 30, 2020
1 parent 33ec02e commit 4d31f3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/components/cvaa-overlay/main-captions_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {default as Icon, IconType} from '../icon';
import {SampleCaptionsStyleButton} from './sample-captions-style-button';
import {h} from 'preact';
import {withPlayer} from '../player';
import isEqual from '../../utils/is-equal';

/**
* MainWindow component
Expand All @@ -29,16 +28,16 @@ class MainCaptionsWindow extends Component {
componentWillMount() {
const {player} = this.props;

this.captionsStyleDefault = Object.assign(new player.TextStyle(), {
this.captionsStyleDefault = player.TextStyle.fromJson({
backgroundOpacity: player.TextStyle.StandardOpacities.TRANSPARENT
});

this.captionsStyleYellow = Object.assign(new player.TextStyle(), {
this.captionsStyleYellow = player.TextStyle.fromJson({
backgroundOpacity: player.TextStyle.StandardOpacities.TRANSPARENT,
fontColor: player.TextStyle.StandardColors.YELLOW
});

this.captionsStyleBlackBG = Object.assign(new player.TextStyle(), {
this.captionsStyleBlackBG = player.TextStyle.fromJson({
backgroundColor: player.TextStyle.StandardColors.BLACK,
fontColor: player.TextStyle.StandardColors.WHITE
});
Expand Down Expand Up @@ -135,9 +134,9 @@ class MainCaptionsWindow extends Component {
isAdvancedStyleApplied(): boolean {
const {player} = this.props;
return (
!isEqual(player.textStyle, this.captionsStyleDefault) &&
!isEqual(player.textStyle, this.captionsStyleBlackBG) &&
!isEqual(player.textStyle, this.captionsStyleYellow)
!player.textStyle.isEqual(this.captionsStyleDefault) &&
!player.textStyle.isEqual(this.captionsStyleBlackBG) &&
!player.textStyle.isEqual(this.captionsStyleYellow)
);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/cvaa-overlay/sample-captions-style-button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@flow
import {KeyMap} from '../../utils/key-map';
import {Text} from 'preact-i18n';
import isEqual from '../../utils/is-equal';
import style from '../../styles/style.scss';
import {default as Icon, IconType} from '../icon';
import {h} from 'preact';
Expand All @@ -27,7 +26,7 @@ const SampleCaptionsStyleButton = (props: any): React$Element<any> => {
}
}}>
<Text id={'cvaa.sample_caption_tag'} />
{isEqual(props.player.textStyle, props.captionsStyle) ? (
{props.player.textStyle.isEqual(props.captionsStyle) ? (
<div className={style.activeTick}>
<Icon type={IconType.Check} />
</div>
Expand Down

0 comments on commit 4d31f3f

Please sign in to comment.