From c6adb56b27c02c385382c8de886e891a04b0706c Mon Sep 17 00:00:00 2001
From: Shane Osbourne <shane.osbourne8@gmail.com>
Date: Fri, 31 Jan 2025 15:59:38 +0000
Subject: [PATCH] revert

---
 .../new-tab/app/activity/ActivityProvider.js  | 94 +++++++++----------
 special-pages/pages/new-tab/app/index.js      |  7 +-
 special-pages/pages/new-tab/app/settings.js   | 19 ++--
 3 files changed, 52 insertions(+), 68 deletions(-)

diff --git a/special-pages/pages/new-tab/app/activity/ActivityProvider.js b/special-pages/pages/new-tab/app/activity/ActivityProvider.js
index 0fbc1194da..285d4ecbbc 100644
--- a/special-pages/pages/new-tab/app/activity/ActivityProvider.js
+++ b/special-pages/pages/new-tab/app/activity/ActivityProvider.js
@@ -95,58 +95,50 @@ export function ActivityProvider(props) {
  * @return {NormalizedActivity}
  */
 function normalizeItems(prev, data) {
-    /** @type {Record<string, boolean>} */
-    const nextFavorites = {};
-    /** @type {Record<string, Item>} */
-    const nextItems = {};
-    /** @type {Record<string, HistoryEntry[]>} */
-    const nextHistory = {};
-    /** @type {Record<string, TrackingStatus>} */
-    const nextTrackingStatus = {};
-
-    for (const x of data.activity) {
-        nextFavorites[x.url] = x.favorite;
-        {
-            /** @type {Item} */
-            const next = {
-                etldPlusOne: x.etldPlusOne,
-                title: x.title,
-                url: x.url,
-                faviconMax: x.favicon?.maxAvailableSize ?? DDG_DEFAULT_ICON_SIZE,
-                favoriteSrc: x.favicon?.src,
-                trackersFound: x.trackersFound,
-            };
-            const differs = shallowDiffers(next, prev.items[x.url] || {});
-            nextItems[x.url] = differs ? next : prev.items[x.url] || {};
-        }
-
-        {
-            const differs = shallowDiffers(x.history, prev.history[x.url] || []);
-            nextHistory[x.url] = differs ? [...x.history] : prev.history[x.url] || [];
-        }
-
-        {
-            const prevItem = prev.trackingStatus[x.url] || {
-                totalCount: 0,
-                trackerCompanies: [],
-            };
-            const differs = shallowDiffers(x.trackingStatus.trackerCompanies, prevItem.trackerCompanies);
-            if (prevItem.totalCount !== x.trackingStatus.totalCount || differs) {
-                nextTrackingStatus[x.url] = {
-                    totalCount: x.trackingStatus.totalCount,
-                    trackerCompanies: [...x.trackingStatus.trackerCompanies],
-                };
-            } else {
-                nextTrackingStatus[x.url] = prevItem;
-            }
-        }
-    }
-
     return {
-        favorites: nextFavorites,
-        items: nextItems,
-        history: nextHistory,
-        trackingStatus: nextTrackingStatus,
+        favorites: Object.fromEntries(
+            data.activity.map((x) => {
+                return [x.url, x.favorite];
+            }),
+        ),
+        items: Object.fromEntries(
+            data.activity.map((x) => {
+                /** @type {Item} */
+                const next = {
+                    etldPlusOne: x.etldPlusOne,
+                    title: x.title,
+                    url: x.url,
+                    faviconMax: x.favicon?.maxAvailableSize ?? DDG_DEFAULT_ICON_SIZE,
+                    favoriteSrc: x.favicon?.src,
+                    trackersFound: x.trackersFound,
+                };
+                const differs = shallowDiffers(next, prev.items[x.url] || {});
+                return [x.url, differs ? next : prev.items[x.url] || {}];
+            }),
+        ),
+        history: Object.fromEntries(
+            data.activity.map((x) => {
+                const differs = shallowDiffers(x.history, prev.history[x.url] || []);
+                return [x.url, differs ? [...x.history] : prev.history[x.url] || []];
+            }),
+        ),
+        trackingStatus: Object.fromEntries(
+            data.activity.map((x) => {
+                const prevItem = prev.trackingStatus[x.url] || {
+                    totalCount: 0,
+                    trackerCompanies: [],
+                };
+                const differs = shallowDiffers(x.trackingStatus.trackerCompanies, prevItem.trackerCompanies);
+                if (prevItem.totalCount !== x.trackingStatus.totalCount || differs) {
+                    const next = {
+                        totalCount: x.trackingStatus.totalCount,
+                        trackerCompanies: [...x.trackingStatus.trackerCompanies],
+                    };
+                    return [x.url, next];
+                }
+                return [x.url, prevItem];
+            }),
+        ),
     };
 }
 
diff --git a/special-pages/pages/new-tab/app/index.js b/special-pages/pages/new-tab/app/index.js
index 6f4f4844b9..a8940e98fa 100644
--- a/special-pages/pages/new-tab/app/index.js
+++ b/special-pages/pages/new-tab/app/index.js
@@ -58,12 +58,7 @@ export async function init(root, messaging, telemetry, baseEnvironment) {
         .withPlatformName(baseEnvironment.injectName)
         .withPlatformName(init.platform?.name)
         .withPlatformName(baseEnvironment.urlParams.get('platform'))
-        .withFeatureState('customizerDrawer', init.settings?.customizerDrawer)
-        .withFeatureState(
-            'batchedActivityApi',
-            baseEnvironment.urlParams.get('activity.api') === 'batched' ? { state: 'enabled' } : { state: 'disabled' },
-        )
-        .withFeatureState('batchedActivityApi', init.platform.name === 'windows' ? { state: 'enabled' } : { state: 'disabled' });
+        .withFeatureState('customizerDrawer', init.settings?.customizerDrawer);
 
     if (!window.__playwright_01) {
         console.log('environment:', environment);
diff --git a/special-pages/pages/new-tab/app/settings.js b/special-pages/pages/new-tab/app/settings.js
index 43364e80dc..a8008596e3 100644
--- a/special-pages/pages/new-tab/app/settings.js
+++ b/special-pages/pages/new-tab/app/settings.js
@@ -3,16 +3,10 @@ export class Settings {
      * @param {object} params
      * @param {{name: 'macos' | 'windows'}} [params.platform]
      * @param {{state: 'enabled' | 'disabled', autoOpen: boolean}} [params.customizerDrawer]
-     * @param {{state: 'enabled' | 'disabled'}} [params.batchedActivityApi]
      */
-    constructor({
-        platform = { name: 'macos' },
-        customizerDrawer = { state: 'disabled', autoOpen: false },
-        batchedActivityApi = { state: 'disabled' },
-    }) {
+    constructor({ platform = { name: 'macos' }, customizerDrawer = { state: 'disabled', autoOpen: false } }) {
         this.platform = platform;
         this.customizerDrawer = customizerDrawer;
-        this.batchedActivityApi = batchedActivityApi;
     }
 
     withPlatformName(name) {
@@ -28,7 +22,7 @@ export class Settings {
     }
 
     /**
-     * @param {(keyof import("../types/new-tab.js").NewTabPageSettings) | 'batchedActivityApi'} named
+     * @param {keyof import("../types/new-tab.js").NewTabPageSettings} named
      * @param {{state: 'enabled' | 'disabled'} | null | undefined} settings
      * @return {Settings}
      */
@@ -36,9 +30,7 @@ export class Settings {
         if (!settings) return this;
         /** @type {(keyof import("../types/new-tab.js").NewTabPageSettings)[]} */
         const valid = ['customizerDrawer'];
-        const other = ['batchedActivityApi'];
-
-        if (!valid.includes(/** @type {any} */ (named)) && !other.includes(named)) {
+        if (!valid.includes(named)) {
             console.warn(`Excluding invalid feature key ${named}`);
             return this;
         }
@@ -51,4 +43,9 @@ export class Settings {
         }
         return this;
     }
+
+    get batchedActivityApi() {
+        if (this.platform.name === 'windows') return { state: 'enabled' };
+        return { state: 'disabled' };
+    }
 }