Skip to content

Commit 3aeee46

Browse files
committed
comments/naming
1 parent 32f8244 commit 3aeee46

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

special-pages/pages/new-tab/app/activity/mocks/activity.mock-transport.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ export function activityMockTransport() {
3737
const msg = /** @type {any} */ (_msg);
3838
switch (msg.method) {
3939
case 'activity_removeItem': {
40+
// grab the tracker count of the current dataset before we alter it
4041
const oldCount = dataset.activity.reduce((acc, item) => acc + item.trackingStatus.totalCount, 0);
42+
43+
// now filter the items
4144
dataset.activity = dataset.activity.filter((x) => x.url !== msg.params.url);
42-
const cb = subs.get('activity_onDataPatch');
43-
const p = toPatch(dataset.activity);
44-
p.totalTrackersBlocked = oldCount;
45+
46+
// create the patch dataset, and use the original tracker count
47+
const patchParams = toPatch(dataset.activity);
48+
patchParams.totalTrackersBlocked = oldCount;
49+
50+
// simulate the native side pushing the fresh data back into the page.
4551
setTimeout(() => {
46-
cb(p);
52+
const cb = subs.get('activity_onDataPatch');
53+
cb(patchParams);
4754
}, 0);
4855
break;
4956
}

0 commit comments

Comments
 (0)