Bug 1860833 - optimize number of calls to getTabClient r=fxview-reviewers,sfoster

Amending the `getRecentTabs` function eliminates one of the duplicate calls to `getTabClients`. I opted for this approach as opposed
to getting tabs from clients or vice versa because that involved a larger refactor that ended up adding unnecessary noise to the
`getRecentTabs` and `getTabClients` return values. Combined with a patch by @sfoster, we have reduced the number of calls from 9 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D194656
This commit is contained in:
Nikki Sharpley 2023-11-28 20:47:40 +00:00
Родитель 6325c833c2
Коммит c84a129983
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -554,7 +554,7 @@ class SyncedTabsInView extends ViewPage {
async getSyncedTabData() {
this.devices = await lazy.SyncedTabs.getTabClients();
let tabs = await lazy.SyncedTabs.getRecentTabs(50, {
let tabs = await lazy.SyncedTabs.createRecentTabsList(this.devices, 50, {
removeAllDupes: false,
removeDeviceDupes: true,
});

Просмотреть файл

@ -300,6 +300,10 @@ export var SyncedTabs = {
return this._internal.syncTabs(force);
},
createRecentTabsList(clients, maxCount, extraParams) {
return this._internal._createRecentTabsList(clients, maxCount, extraParams);
},
sortTabClientsByLastUsed(clients) {
// First sort the list of tabs for each client. Note that
// this module promises that the objects it returns are never
@ -338,6 +342,6 @@ export var SyncedTabs = {
// lastUsed value, and filtered for duplicate URLs
async getRecentTabs(maxCount, extraParams) {
let clients = await this.getTabClients();
return this._internal._createRecentTabsList(clients, maxCount, extraParams);
return this._internal.createRecentTabsList(clients, maxCount, extraParams);
},
};