Skip to content

Commit

Permalink
refactored a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Denys Fedotov authored and Denys Fedotov committed Jan 23, 2025
1 parent d747cbb commit a69959a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,9 +988,12 @@ export function cleanAndSortManifestList(manifests, conf) {
freshManifest.name = fullManifest.name;
freshManifest.selectedVariantName = fullManifest.selectedVariantName;
targetManifestWinsOverServerManifest = config?.env?.name === 'prod' && fullManifest.selectedVariantName.startsWith('target-');
freshManifest.selectedVariant = targetManifestWinsOverServerManifest
? fullManifest.variants[fullManifest.selectedVariantName]
: freshManifest.variants[freshManifest.selectedVariantName];

freshManifest.variants = targetManifestWinsOverServerManifest
? fullManifest.variants
: freshManifest.variants;

freshManifest.selectedVariant = freshManifest.variants[freshManifest.selectedVariantName];
manifestObj[manifest.manifestPath] = freshManifest;
} else {
manifestObj[manifest.manifestPath] = manifest;
Expand All @@ -999,15 +1002,12 @@ export function cleanAndSortManifestList(manifests, conf) {
const manifestConfig = manifestObj[manifest.manifestPath];
const { selectedVariantName, variantNames, placeholderData } = manifestConfig;

if (!targetManifestWinsOverServerManifest) {
if (selectedVariantName && variantNames.includes(selectedVariantName)) {
manifestConfig.run = true;
manifestConfig.selectedVariant = manifestConfig.variants[selectedVariantName];
} else {
/* c8 ignore next 2 */
manifestConfig.selectedVariantName = 'default';
manifestConfig.selectedVariant = 'default';
}
if (selectedVariantName && variantNames.includes(selectedVariantName)) {
manifestConfig.selectedVariant = manifestConfig.variants[selectedVariantName];
} else {
/* c8 ignore next 2 */
manifestConfig.selectedVariantName = 'default';
manifestConfig.selectedVariant = 'default';
}

parsePlaceholders(placeholderData, getConfig(), manifestConfig.selectedVariantName);
Expand Down

0 comments on commit a69959a

Please sign in to comment.