(WeightedHighlights, prefWeightedHighlights, TopSites, History, Spotlight, Experiments) => { // Remove duplicates // Note that we have to limit the length of topsites, spotlight so we // don't dedupe against stuff that isn't shown let [topSitesRows, spotlightRows] = dedupe.group([TopSites.rows.slice(0, TOP_SITES_LENGTH), Spotlight.rows]); // Find the index of the recommendation. If we have an index, find that recommmendation and put it // in the third highlights spot let recommendation = spotlightRows.findIndex(element => element.recommended); if (recommendation >= 0) { spotlightRows.splice(2, 0, spotlightRows.splice(recommendation, 1)[0]); } spotlightRows = spotlightRows.slice(0, SPOTLIGHT_LENGTH); const historyRows = dedupe.group([ topSitesRows, spotlightRows, History.rows])[2]; let topHighlights = spotlightRows; if (prefWeightedHighlights) { const weightedRows = WeightedHighlights.rows.concat(WeightedHighlights.init ? firstRunData.Highlights : []); topHighlights = assignImageAndBackgroundColor(weightedRows); } return { TopSites: Object.assign({}, TopSites, {rows: topSitesRows}), Spotlight: Object.assign({}, Spotlight, {rows: topHighlights, weightedHighlights: prefWeightedHighlights}), TopActivity: Object.assign({}, History, {rows: historyRows}), isReady: TopSites.init && History.init && Spotlight.init && Experiments.init && WeightedHighlights.init, showRecommendationOption: Experiments.values.recommendedHighlight }; }
(TopSites, History, Spotlight) => { // Remove duplicates // Note that we have to limit the length of topsites, spotlight so we // don't dedupe against stuff that isn't shown let [topSitesRows, spotlightRows] = dedupe.group([TopSites.rows.slice(0, TOP_SITES_LENGTH), Spotlight.rows]); spotlightRows = spotlightRows.slice(0, SPOTLIGHT_LENGTH); const historyRows = dedupe.group([ topSitesRows, spotlightRows, History.rows])[2]; return { TopSites: Object.assign({}, TopSites, {rows: topSitesRows}), Spotlight: Object.assign({}, Spotlight, {rows: spotlightRows}), TopActivity: Object.assign({}, History, {rows: historyRows}), isReady: TopSites.init && History.init && Spotlight.init }; }
it("should dedupe TopSites, Spotlight, and TopActivity", () => { const groups = [state.TopSites.rows, state.Spotlight.rows, state.TopActivity.rows]; assert.deepEqual(groups, dedupe.group(groups)); });