I have two buttons to link and unlink a social sign-in provider.
<button class="btn btn-default" ng-if="!user.facebook" ng-click="link('facebook')">
Link Facebook
</button>
<button class="btn btn-danger" ng-if="user.facebook" ng-click="unlink('facebook')">
Unlink Facebook
</button>
Now whenever I hit Unlink Facebook for example, I send a POST request to the server, and then make a separate HTTP request to grab up-to-date user information right after unlinking (or linking) an account.
The problem that I don't understand is why there is almost a whole second delay before Unlink Facebook disappears.
I have two buttons. They cannot be active at the same time because the have the exact opposite conditions. If for example I have already linked an account, when I try to unlink it, as soon as the data is received, a new button appears Link Facebook (as it should) but it takes almost another second before Unlink Facebook button disappears.
I am almost certain this has something to do with AngularJS lifecycle management. Is this possible to fix?