Skip to content

Commit eb20a77

Browse files
committed
revert
1 parent c0ac106 commit eb20a77

File tree

3 files changed

+52
-68
lines changed

3 files changed

+52
-68
lines changed

special-pages/pages/new-tab/app/activity/ActivityProvider.js

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -95,58 +95,50 @@ export function ActivityProvider(props) {
9595
* @return {NormalizedActivity}
9696
*/
9797
function normalizeItems(prev, data) {
98-
/** @type {Record<string, boolean>} */
99-
const nextFavorites = {};
100-
/** @type {Record<string, Item>} */
101-
const nextItems = {};
102-
/** @type {Record<string, HistoryEntry[]>} */
103-
const nextHistory = {};
104-
/** @type {Record<string, TrackingStatus>} */
105-
const nextTrackingStatus = {};
106-
107-
for (const x of data.activity) {
108-
nextFavorites[x.url] = x.favorite;
109-
{
110-
/** @type {Item} */
111-
const next = {
112-
etldPlusOne: x.etldPlusOne,
113-
title: x.title,
114-
url: x.url,
115-
faviconMax: x.favicon?.maxAvailableSize ?? DDG_DEFAULT_ICON_SIZE,
116-
favoriteSrc: x.favicon?.src,
117-
trackersFound: x.trackersFound,
118-
};
119-
const differs = shallowDiffers(next, prev.items[x.url] || {});
120-
nextItems[x.url] = differs ? next : prev.items[x.url] || {};
121-
}
122-
123-
{
124-
const differs = shallowDiffers(x.history, prev.history[x.url] || []);
125-
nextHistory[x.url] = differs ? [...x.history] : prev.history[x.url] || [];
126-
}
127-
128-
{
129-
const prevItem = prev.trackingStatus[x.url] || {
130-
totalCount: 0,
131-
trackerCompanies: [],
132-
};
133-
const differs = shallowDiffers(x.trackingStatus.trackerCompanies, prevItem.trackerCompanies);
134-
if (prevItem.totalCount !== x.trackingStatus.totalCount || differs) {
135-
nextTrackingStatus[x.url] = {
136-
totalCount: x.trackingStatus.totalCount,
137-
trackerCompanies: [...x.trackingStatus.trackerCompanies],
138-
};
139-
} else {
140-
nextTrackingStatus[x.url] = prevItem;
141-
}
142-
}
143-
}
144-
14598
return {
146-
favorites: nextFavorites,
147-
items: nextItems,
148-
history: nextHistory,
149-
trackingStatus: nextTrackingStatus,
99+
favorites: Object.fromEntries(
100+
data.activity.map((x) => {
101+
return [x.url, x.favorite];
102+
}),
103+
),
104+
items: Object.fromEntries(
105+
data.activity.map((x) => {
106+
/** @type {Item} */
107+
const next = {
108+
etldPlusOne: x.etldPlusOne,
109+
title: x.title,
110+
url: x.url,
111+
faviconMax: x.favicon?.maxAvailableSize ?? DDG_DEFAULT_ICON_SIZE,
112+
favoriteSrc: x.favicon?.src,
113+
trackersFound: x.trackersFound,
114+
};
115+
const differs = shallowDiffers(next, prev.items[x.url] || {});
116+
return [x.url, differs ? next : prev.items[x.url] || {}];
117+
}),
118+
),
119+
history: Object.fromEntries(
120+
data.activity.map((x) => {
121+
const differs = shallowDiffers(x.history, prev.history[x.url] || []);
122+
return [x.url, differs ? [...x.history] : prev.history[x.url] || []];
123+
}),
124+
),
125+
trackingStatus: Object.fromEntries(
126+
data.activity.map((x) => {
127+
const prevItem = prev.trackingStatus[x.url] || {
128+
totalCount: 0,
129+
trackerCompanies: [],
130+
};
131+
const differs = shallowDiffers(x.trackingStatus.trackerCompanies, prevItem.trackerCompanies);
132+
if (prevItem.totalCount !== x.trackingStatus.totalCount || differs) {
133+
const next = {
134+
totalCount: x.trackingStatus.totalCount,
135+
trackerCompanies: [...x.trackingStatus.trackerCompanies],
136+
};
137+
return [x.url, next];
138+
}
139+
return [x.url, prevItem];
140+
}),
141+
),
150142
};
151143
}
152144

special-pages/pages/new-tab/app/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ export async function init(root, messaging, telemetry, baseEnvironment) {
5858
.withPlatformName(baseEnvironment.injectName)
5959
.withPlatformName(init.platform?.name)
6060
.withPlatformName(baseEnvironment.urlParams.get('platform'))
61-
.withFeatureState('customizerDrawer', init.settings?.customizerDrawer)
62-
.withFeatureState(
63-
'batchedActivityApi',
64-
baseEnvironment.urlParams.get('activity.api') === 'batched' ? { state: 'enabled' } : { state: 'disabled' },
65-
)
66-
.withFeatureState('batchedActivityApi', init.platform.name === 'windows' ? { state: 'enabled' } : { state: 'disabled' });
61+
.withFeatureState('customizerDrawer', init.settings?.customizerDrawer);
6762

6863
if (!window.__playwright_01) {
6964
console.log('environment:', environment);

special-pages/pages/new-tab/app/settings.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@ export class Settings {
33
* @param {object} params
44
* @param {{name: 'macos' | 'windows'}} [params.platform]
55
* @param {{state: 'enabled' | 'disabled', autoOpen: boolean}} [params.customizerDrawer]
6-
* @param {{state: 'enabled' | 'disabled'}} [params.batchedActivityApi]
76
*/
8-
constructor({
9-
platform = { name: 'macos' },
10-
customizerDrawer = { state: 'disabled', autoOpen: false },
11-
batchedActivityApi = { state: 'disabled' },
12-
}) {
7+
constructor({ platform = { name: 'macos' }, customizerDrawer = { state: 'disabled', autoOpen: false } }) {
138
this.platform = platform;
149
this.customizerDrawer = customizerDrawer;
15-
this.batchedActivityApi = batchedActivityApi;
1610
}
1711

1812
withPlatformName(name) {
@@ -28,17 +22,15 @@ export class Settings {
2822
}
2923

3024
/**
31-
* @param {(keyof import("../types/new-tab.js").NewTabPageSettings) | 'batchedActivityApi'} named
25+
* @param {keyof import("../types/new-tab.js").NewTabPageSettings} named
3226
* @param {{state: 'enabled' | 'disabled'} | null | undefined} settings
3327
* @return {Settings}
3428
*/
3529
withFeatureState(named, settings) {
3630
if (!settings) return this;
3731
/** @type {(keyof import("../types/new-tab.js").NewTabPageSettings)[]} */
3832
const valid = ['customizerDrawer'];
39-
const other = ['batchedActivityApi'];
40-
41-
if (!valid.includes(/** @type {any} */ (named)) && !other.includes(named)) {
33+
if (!valid.includes(named)) {
4234
console.warn(`Excluding invalid feature key ${named}`);
4335
return this;
4436
}
@@ -51,4 +43,9 @@ export class Settings {
5143
}
5244
return this;
5345
}
46+
47+
get batchedActivityApi() {
48+
if (this.platform.name === 'windows') return { state: 'enabled' };
49+
return { state: 'disabled' };
50+
}
5451
}

0 commit comments

Comments
 (0)