File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
special-pages/pages/new-tab/app/activity/mocks Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,20 @@ export function activityMockTransport() {
37
37
const msg = /** @type {any } */ ( _msg ) ;
38
38
switch ( msg . method ) {
39
39
case 'activity_removeItem' : {
40
+ // grab the tracker count of the current dataset before we alter it
40
41
const oldCount = dataset . activity . reduce ( ( acc , item ) => acc + item . trackingStatus . totalCount , 0 ) ;
42
+
43
+ // now filter the items
41
44
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.
45
51
setTimeout ( ( ) => {
46
- cb ( p ) ;
52
+ const cb = subs . get ( 'activity_onDataPatch' ) ;
53
+ cb ( patchParams ) ;
47
54
} , 0 ) ;
48
55
break ;
49
56
}
You can’t perform that action at this time.
0 commit comments