1- import type { GistMessage , ResolvedMessageProperties } from '../types' ;
1+ import type { GistMessage , ResolvedMessageProperties , StepDisplayConfig } from '../types' ;
22
33export const MESSAGE_PROPERTY_DEFAULTS : ResolvedMessageProperties = {
44 isEmbedded : false ,
@@ -19,6 +19,35 @@ export const MESSAGE_PROPERTY_DEFAULTS: ResolvedMessageProperties = {
1919 hasCustomWidth : false ,
2020} ;
2121
22+ function resolveMessageTooltipColor ( message : GistMessage ) : string {
23+ let tooltipColor = MESSAGE_PROPERTY_DEFAULTS . tooltipArrowColor ;
24+
25+ if ( ( message ?. properties ?. gist ?. tooltipArrowColor ?. length ?? 0 ) > 0 ) {
26+ tooltipColor = message ! . properties ! . gist ! . tooltipArrowColor ! ;
27+ } else {
28+ if ( ! Array . isArray ( message ?. displaySettings ) || message . displaySettings . length === 0 ) {
29+ return tooltipColor ;
30+ }
31+
32+ // Try to match savedStepName, otherwise use first step
33+ let step : StepDisplayConfig = message . displaySettings [ 0 ] ;
34+ if ( message . savedStepName ) {
35+ const matchedStep = message . displaySettings . find (
36+ ( s : StepDisplayConfig ) => s ?. stepName === message . savedStepName && s . displaySettings
37+ ) ;
38+ if ( matchedStep ) {
39+ step = matchedStep ;
40+ }
41+ }
42+
43+ if ( step ?. displaySettings ?. tooltipArrowColor ) {
44+ tooltipColor = step . displaySettings . tooltipArrowColor ;
45+ }
46+ }
47+
48+ return tooltipColor ;
49+ }
50+
2251export function resolveMessageProperties ( message : GistMessage ) : ResolvedMessageProperties {
2352 const defaults = MESSAGE_PROPERTY_DEFAULTS ;
2453
@@ -34,7 +63,7 @@ export function resolveMessageProperties(message: GistMessage): ResolvedMessageP
3463 hasPosition : ! ! gist . position ,
3564 tooltipPosition : gist . tooltipPosition || '' ,
3665 hasTooltipPosition : ! ! gist . tooltipPosition ,
37- tooltipArrowColor : gist . tooltipArrowColor || defaults . tooltipArrowColor ,
66+ tooltipArrowColor : resolveMessageTooltipColor ( message ) ,
3867 shouldScale : ! ! gist . scale ,
3968 campaignId : gist . campaignId ?? null ,
4069 messageWidth :
0 commit comments