Skip to content

Commit 6f5588f

Browse files
committed
poc query de-duplication
1 parent 34c22e3 commit 6f5588f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

special-pages/pages/history/app/history.service.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export class HistoryService {
2929
});
3030
},
3131
}).withUpdater((old, next, trigger) => {
32+
/**
33+
* Manual updates, always accept the update
34+
*/
3235
if (trigger === 'manual') {
3336
return next;
3437
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class Service {
201201
}
202202

203203
class NonOverlapping {
204-
/** @type {null|{promise: any}} */
204+
/** @type {null|{promise: any, id: string}} */
205205
_ongoing = null;
206206

207207
/**
@@ -219,12 +219,19 @@ class NonOverlapping {
219219
if (this._ongoing?.promise) {
220220
this._ongoing.promise.cancelled = true;
221221
}
222+
// todo: where to put this de-duplication of queries?
223+
const id = JSON.stringify(params);
224+
if (this._ongoing?.id === id) {
225+
return;
226+
}
227+
222228
// eslint-disable-next-line promise/prefer-await-to-then
223229
const promise = this.service.impl.initial(params).then((data) => {
224230
if (/** @type {any} */ (promise).cancelled) return;
225231
this.service.accept(data, 'trigger-fetch');
226232
this._ongoing = null;
227233
});
228-
this._ongoing = { promise };
234+
235+
this._ongoing = { promise, id };
229236
}
230237
}

0 commit comments

Comments
 (0)