Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.

Commit 5757235

Browse files
authored
Merge pull request #936 from uPortal-Project/drop-duplicates-during-layout-migrate
drop duplicate fnames when migrating layout from old layout backend
2 parents c55e0cf + c135289 commit 5757235

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Versions in this document should match those
1111

1212
## Next
1313

14+
+ Drops duplicate fnames when migrating from old layout backend
15+
to new layout backend.
16+
1417
## 14.0.1 - 2021-11-22
1518

1619
+ Built on [uPortal-app-framework 21.0.2][].

web/src/main/webapp/my-app/layout/services.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,19 @@ define(['angular', 'jquery'], function(angular, $) {
8383
var oldArrayOfMaps = formattedOldLayout.layout;
8484
var newLayoutRepresentation = [];
8585

86+
// use a Set to drop subsequent duplicates when migrating
87+
var fnameSet = new Set();
8688
for (var i = 0; i < oldArrayOfMaps.length; i++) {
8789
var fname = oldArrayOfMaps[i].fname;
8890
$log.log('Object in the array is ' +
8991
angular.toJson(oldArrayOfMaps[i]));
9092
$log.log('fname is ' + fname);
91-
newLayoutRepresentation.push(fname);
93+
if (!fnameSet.has(fname)) {
94+
fnameSet.add(fname);
95+
newLayoutRepresentation.push(fname);
96+
} else {
97+
$log.log('Dropped duplicate fname ' + fname);
98+
}
9299
}
93100

94101
$log.log('persistAndUse: ' +

0 commit comments

Comments
 (0)