Skip to content

Commit

Permalink
Merge pull request #40997 from Skakruk/40044-track-active-tab
Browse files Browse the repository at this point in the history
Fix ActiveClientManager doesn't track the currently active tab well and needs improved
  • Loading branch information
tgolen authored May 10, 2024
2 parents e7c29e6 + 0de4ae2 commit d7216ea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libs/ActiveClientManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ Onyx.connect({
},
});

const cleanUpClientId = () => {
activeClients = activeClients.filter((id) => id !== clientID);
ActiveClients.setActiveClients(activeClients);
};

/**
* Add our client ID to the list of active IDs.
* We want to ensure we have no duplicates and that the activeClient gets added at the end of the array (see isClientTheLeader)
Expand All @@ -53,6 +58,8 @@ const init: Init = () => {
activeClients = activeClients.filter((id) => id !== clientID);
activeClients.push(clientID);
ActiveClients.setActiveClients(activeClients).then(resolveSavedSelfPromise);

window.addEventListener('beforeunload', cleanUpClientId);
};

/**
Expand Down

0 comments on commit d7216ea

Please sign in to comment.