Skip to content

Commit

Permalink
Bug 1860833 - optimize number of calls to getTabClient r=fxview-revie…
Browse files Browse the repository at this point in the history
…wers,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
  • Loading branch information
nikk15 committed Nov 28, 2023
1 parent 6325c83 commit c84a129
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser/components/firefoxview/syncedtabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
6 changes: 5 additions & 1 deletion services/sync/modules/SyncedTabs.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
},
};

0 comments on commit c84a129

Please sign in to comment.