Skip to content

Commit 2604373

Browse files
ignore retried setTab if already set to avoid race condition
1 parent 4bd0fe8 commit 2604373

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/js/controllers/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,10 +1205,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r
12051205

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

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

0 commit comments

Comments
 (0)