Return after invoking a completion handler

This commit is contained in:
Cameron Gutman 2016-07-10 21:51:29 -07:00
parent 237fcdeef8
commit c2fde815fa

View File

@ -104,12 +104,14 @@ function pairTo(host, onSuccess, onFailure) {
snackbarLog('ERROR: cert has not been generated yet. Is NaCl initialized?'); snackbarLog('ERROR: cert has not been generated yet. Is NaCl initialized?');
console.log("User wants to pair, and we still have no cert. Problem = very yes."); console.log("User wants to pair, and we still have no cert. Problem = very yes.");
onFailure(); onFailure();
return;
} }
api = new NvHTTP(host, myUniqueid); api = new NvHTTP(host, myUniqueid);
api.refreshServerInfo().then(function (ret) { api.refreshServerInfo().then(function (ret) {
if (api.paired) { if (api.paired) {
onSuccess(); onSuccess();
return;
} }
var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4); var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4);
@ -126,12 +128,12 @@ function pairTo(host, onSuccess, onFailure) {
$('#pairingDialogText').html('Error: failed to pair with ' + host + '. failure reason unknown.'); $('#pairingDialogText').html('Error: failed to pair with ' + host + '. failure reason unknown.');
} }
onFailure(); onFailure();
return;
} }
snackbarLog('Pairing successful'); snackbarLog('Pairing successful');
pairingDialog.close(); pairingDialog.close();
onSuccess(); onSuccess();
}, function (failedPairing) { }, function (failedPairing) {
snackbarLog('Failed pairing to: ' + host); snackbarLog('Failed pairing to: ' + host);
console.log('pairing failed, and returned ' + failedPairing); console.log('pairing failed, and returned ' + failedPairing);