Skip to content

Commit

Permalink
fix(FEC-13650): Player v7 | CTA | CTA doesn't show when seeking backw…
Browse files Browse the repository at this point in the history
…ards for the second CTA.
  • Loading branch information
SivanA-Kaltura authored Jan 24, 2024
2 parents 6e01d31 + b4d91a0 commit d8fa6ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/call-to-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CallToAction extends BasePlugin<CallToActionConfig> {
}

if (this.messages.length) {
this.eventManager.listenOnce(this.player, this.player.Event.Core.LOADED_DATA, () => this.sortMessages());
this.eventManager.listen(this.player, this.player.Event.Core.TIME_UPDATE, () => this.onTimeUpdate());
this.eventManager.listen(this.player, this.player.Event.Core.SEEKED, () => this.onSeeked());
}
Expand Down Expand Up @@ -74,6 +75,7 @@ class CallToAction extends BasePlugin<CallToActionConfig> {
if (this.activeMessage) {
this.callToActionManager.removeMessage();
this.activeMessageEndTime = -1;
this.activeMessage = null;
}

for (const message of this.messages) {
Expand Down Expand Up @@ -112,9 +114,14 @@ class CallToAction extends BasePlugin<CallToActionConfig> {
) {
this.callToActionManager.removeMessage();
this.activeMessageEndTime = -1;
this.activeMessage = null;
}
}

private sortMessages() {
this.messages.sort((messageA: MessageData, messageB: MessageData) => this.compareMessagesByTiming(messageA, messageB));
}

private filterMessages() {
this.messages = this.config.messages
.map(message => {
Expand Down Expand Up @@ -148,8 +155,7 @@ class CallToAction extends BasePlugin<CallToActionConfig> {
const contentValid = message.description || message.title || message.buttons.length;

return durationValid && timingValid && contentValid;
})
.sort((messageA: MessageData, messageB: MessageData) => this.compareMessagesByTiming(messageA, messageB));
});
}

private compareMessagesByTiming(messageA: MessageData, messageB: MessageData) {
Expand All @@ -173,6 +179,8 @@ class CallToAction extends BasePlugin<CallToActionConfig> {
private showMessage(message: MessageDataWithTracking, duration?: number) {
this.activeMessage = message;
message.wasShown = true;

this.callToActionManager.removeMessage();
this.callToActionManager.addMessage({
message,
duration,
Expand Down
4 changes: 2 additions & 2 deletions src/components/text-with-tooltip/text-with-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TextWithTooltip = ({text, numberOfLines}: {text: string; numberOfLines: nu
const [isFinalized, setIsFinalized] = useState(false);

useLayoutEffect(() => {
if (textRef?.current && comparisonTextRef?.current) {
if (!isFinalized && textRef?.current && comparisonTextRef?.current) {
setIsFinalized(true);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand All @@ -22,7 +22,7 @@ const TextWithTooltip = ({text, numberOfLines}: {text: string; numberOfLines: nu
const comparisonTextHeight = comparisonTextRef?.current?.getBoundingClientRect().height;
setShowTooltip(textHeight < comparisonTextHeight);
}
}, [isFinalized]);
});

const textElement = (
<div ref={textRef} style={{'-webkit-line-clamp': numberOfLines}} className={styles.text}>
Expand Down

0 comments on commit d8fa6ee

Please sign in to comment.