Skip to content
Snippets Groups Projects
Commit d41a1ba8 authored by Alexey Lunin's avatar Alexey Lunin
Browse files

Refactor identityPullAvatarFromGravatar with async await

parent e904107b
No related branches found
No related tags found
1 merge request!22Modify usage of Gravatar
...@@ -610,35 +610,34 @@ const connection = Penpal.connectToParent({ ...@@ -610,35 +610,34 @@ const connection = Penpal.connectToParent({
return responseToClient; return responseToClient;
}, },
identityPullAvatarFromGravatar() { identityPullAvatarFromGravatar: async () => {
return new Penpal.Promise(result => { const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); if (authenticationPublicKey === null) {
if (authenticationPublicKey === null) { return {
result({"data" : "", data : "",
"code" : "400", code : "400",
"status" : "Identity not authenticated" status : "Identity not authenticated"
}) };
} }
if (window.loadedIdentities[authenticationPublicKey] === null) { if (window.loadedIdentities[authenticationPublicKey] === null) {
result({"data" : "", return {
"code" : "400", data : "",
"status" : "Identity not authenticated" code : "400",
}) status : "Identity not authenticated"
} }
}
var success = extendPinCodeTtl(authenticationPublicKey); var success = extendPinCodeTtl(authenticationPublicKey);
if(success === false) { if(success === false) {
result({"data" : "", return {
"code" : "400", data : "",
"status" : "Identity not authenticated" code : "400",
}) status : "Identity not authenticated"
} };
}
executeRestfulFunction("private", viamApi, viamApi.identityPullAvatarFromGravatar).then(executeResult => { return await executeRestfulFunction("private", viamApi, viamApi.identityPullAvatarFromGravatar);
result(executeResult);
});
});
}, },
identityAddNewDevice() { identityAddNewDevice() {
return new Penpal.Promise(result => { return new Penpal.Promise(result => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment