Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #92 from mdklab/fix-91-error-processing
Browse files Browse the repository at this point in the history
fix: incorrect processing if google api script loading is failed
  • Loading branch information
maximepvrt authored May 16, 2017
2 parents ed166f5 + 5a3356c commit f5a5aac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/factories/GApi.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
executeCallbacks(api);
}
});
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
}
Expand Down
18 changes: 17 additions & 1 deletion src/factories/GAuth.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
isLoad = true;
deferred.resolve();
});
}, function (e) {
deferred.reject(e);
});
} else {
deferred.resolve();
}
return deferred.promise;
}

function signin(mode, authorizeCallback) {
function signin(mode, authorizeCallback, errorCallback) {
function executeSignin(mode, authorizeCallback){
var config = {client_id: CLIENT_ID, scope: SCOPE, immediate: false, authuser: -1, response_type: RESPONSE_TYPE};
if(mode) {
Expand All @@ -42,6 +44,10 @@
} else {
load().then(function (){
executeSignin(mode, authorizeCallback);
}, function (e) {
if (errorCallback) {
errorCallback(e);
}
});
}
}
Expand Down Expand Up @@ -125,6 +131,8 @@
}, function () {
deferred.reject();
});
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
},
Expand All @@ -137,6 +145,8 @@
}, function () {
deferred.reject();
});
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
},
Expand All @@ -150,6 +160,8 @@
}, function () {
deferred.reject();
});
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
},
Expand All @@ -158,6 +170,8 @@
var deferred = $q.defer();
load().then(function (){
deferred.resolve($window.gapi.auth.getToken());
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
},
Expand All @@ -169,6 +183,8 @@
GData.isLogin(false);
GData.getUser(null);
deferred.resolve();
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
},
Expand Down
7 changes: 7 additions & 0 deletions src/factories/GClient.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
deferred.reject(e);
});
};
$window.onerror = function (e) {
$timeout(function () {
deferred.reject(e);
});
};
script.src = src;
$document[0].body.appendChild(script);
return deferred.promise;
Expand All @@ -44,6 +49,8 @@
for(var i= 0; i < OBSERVER_CALLBACKS.length; i++){
OBSERVER_CALLBACKS[i].resolve();
}
}, function(e) {
deferred.reject(e);
});
}
}
Expand Down

0 comments on commit f5a5aac

Please sign in to comment.