diff --git a/frontend/app/components/Session_/WarnBadge.tsx b/frontend/app/components/Session_/WarnBadge.tsx index db5d244c4..4f47f8767 100644 --- a/frontend/app/components/Session_/WarnBadge.tsx +++ b/frontend/app/components/Session_/WarnBadge.tsx @@ -40,6 +40,12 @@ interface WarnBadgeExtraProps { trackerWarnClassName?: string; } +type Warns = [ + localhostWarn: boolean, + trackerWarn: boolean, + virtualElsFailWarn: boolean, +]; + const WarnBadge = React.memo( ({ currentLocation, @@ -66,31 +72,35 @@ const WarnBadge = React.memo( localStorage.getItem(localhostWarnSiteKey) !== '1'; const localhostWarnActive = Boolean( currentLocation && - defaultLocalhostWarn && - /(localhost)|(127.0.0.1)|(0.0.0.0)/.test(currentLocation) - ) + defaultLocalhostWarn && + /(localhost)|(127.0.0.1)|(0.0.0.0)/.test(currentLocation), + ); const trackerVersion = window.env.TRACKER_VERSION ?? undefined; const trackerVerDiff = compareVersions(version, trackerVersion); const trackerWarnActive = trackerVerDiff !== VersionComparison.Same; - const [warnings, setWarnings] = React.useState<[localhostWarn: boolean, trackerWarn: boolean, virtualElsFailWarn: boolean]>([localhostWarnActive, trackerWarnActive, virtualElsFailed]) + const [warnings, setWarnings] = React.useState([ + localhostWarnActive, + trackerWarnActive, + virtualElsFailed, + ]); React.useEffect(() => { - setWarnings([localhostWarnActive, trackerWarnActive, virtualElsFailed]) - }, [localhostWarnActive, trackerWarnActive, virtualElsFailed]) + setWarnings([localhostWarnActive, trackerWarnActive, virtualElsFailed]); + }, [localhostWarnActive, trackerWarnActive, virtualElsFailed]); const closeWarning = (type: 0 | 1 | 2) => { if (type === 1) { localStorage.setItem(localhostWarnSiteKey, '1'); } - setWarnings((prev) => { + setWarnings((prev: Warns) => { const newWarnings = [...prev]; newWarnings[type] = false; - return newWarnings; + return newWarnings as Warns; }); }; - if (!warnings.some(el => el === true)) return null; + if (!warnings.some((el) => el === true)) return null; // Default container styles and classes const defaultContainerStyle: React.CSSProperties = { @@ -101,11 +111,15 @@ const WarnBadge = React.memo( transform: 'translate(-50%, 80%)', fontWeight: 500, }; - const defaultContainerClass = "flex flex-col gap-2"; - const defaultWarnClass = "px-3 py-.5 border border-gray-lighter shadow-sm rounded bg-active-blue flex items-center justify-between"; + const defaultContainerClass = 'flex flex-col gap-2'; + const defaultWarnClass = + 'px-3 py-.5 border border-gray-lighter shadow-sm rounded bg-active-blue flex items-center justify-between'; // Merge defaults with any overrides - const mergedContainerStyle = { ...defaultContainerStyle, ...containerStyle }; + const mergedContainerStyle = { + ...defaultContainerStyle, + ...containerStyle, + }; const mergedContainerClassName = containerClassName ? defaultContainerClass + ' ' + containerClassName : defaultContainerClass; @@ -117,12 +131,12 @@ const WarnBadge = React.memo( : defaultWarnClass; return ( -
+
{warnings[0] ? ( -
+
{t('Some assets may load incorrectly on localhost.')} -
-
- {t('Tracker version')} {version} +
+
+ {t('Tracker version')}{' '} + {version} {t('for this recording is')}{' '} {trackerVerDiff === VersionComparison.Lower ? 'lower ' : 'ahead of '} - {t('the current')}{trackerVersion}{t('version')}. + {t('the current')} + {trackerVersion} + {t('version')}.
-