Skip to content

Commit

Permalink
ignore retried setTab if already set to avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofbyteball committed May 31, 2022
1 parent 4bd0fe8 commit 2604373
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/controllers/index.js
Expand Up @@ -1205,10 +1205,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r

if (!document.getElementById('menu-' + tab) && ++tries < 5) {
console.log("will retry setTab later:", tab, reset, tries, switchState);
self.waitingForMenu = true;
return $timeout(function() {
self.setTab(tab, reset, tries, switchState);
if (self.waitingForMenu) // skip if another call has already successfully set (another) tab
self.setTab(tab, reset, tries, switchState);
else
console.log("setTab retry ", tab, reset, tries, switchState, ": tab already set to ", self.tab);
}, (tries === 1) ? 10 : 300);
}
self.waitingForMenu = false;

if (!self.tab || !$state.is('walletHome'))
$rootScope.tab = self.tab = 'walletHome';
Expand Down

0 comments on commit 2604373

Please sign in to comment.