removed use of 'deferred' from promises
This commit is contained in:
parent
4161d1da32
commit
0d47028105
6 changed files with 10 additions and 20 deletions
|
@ -20,7 +20,7 @@ function upsert (Model, values, condition) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkNameAvailability (name) {
|
function checkNameAvailability (name) {
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// find any records where the name is used
|
// find any records where the name is used
|
||||||
db.File
|
db.File
|
||||||
.findAll({ where: { name } })
|
.findAll({ where: { name } })
|
||||||
|
@ -50,12 +50,11 @@ function checkNameAvailability (name) {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
publish (publishParams, fileName, fileType) {
|
publish (publishParams, fileName, fileType) {
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 1. make sure the name is available
|
// 1. make sure the name is available
|
||||||
checkNameAvailability(publishParams.name)
|
checkNameAvailability(publishParams.name)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
@ -108,7 +107,6 @@ module.exports = {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
},
|
},
|
||||||
checkNameAvailability (name) {
|
checkNameAvailability (name) {
|
||||||
return checkNameAvailability(name);
|
return checkNameAvailability(name);
|
||||||
|
|
|
@ -114,7 +114,7 @@ module.exports = {
|
||||||
return getAssetByClaimId(fullClaimId, name);
|
return getAssetByClaimId(fullClaimId, name);
|
||||||
},
|
},
|
||||||
serveClaimByName (claimName) {
|
serveClaimByName (claimName) {
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 1. get the top free, public claims
|
// 1. get the top free, public claims
|
||||||
getAllFreePublicClaims(claimName)
|
getAllFreePublicClaims(claimName)
|
||||||
.then(freePublicClaimList => {
|
.then(freePublicClaimList => {
|
||||||
|
@ -152,6 +152,5 @@ module.exports = {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@ const serveHelpers = require('../helpers/serveHelpers.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
showClaimByName (claimName) {
|
showClaimByName (claimName) {
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 1. get the top free, public claims
|
// 1. get the top free, public claims
|
||||||
getAllFreePublicClaims(claimName)
|
getAllFreePublicClaims(claimName)
|
||||||
.then(freePublicClaimList => {
|
.then(freePublicClaimList => {
|
||||||
|
@ -51,11 +51,10 @@ module.exports = {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
},
|
},
|
||||||
showClaimByClaimId (name, claimId) {
|
showClaimByClaimId (name, claimId) {
|
||||||
logger.debug(`Getting claim name: ${name} by claimid: ${claimId}`);
|
logger.debug(`Getting claim name: ${name} by claimid: ${claimId}`);
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 1. check locally for the claim
|
// 1. check locally for the claim
|
||||||
const uri = `${name}#${claimId}`;
|
const uri = `${name}#${claimId}`;
|
||||||
db.File
|
db.File
|
||||||
|
@ -107,10 +106,9 @@ module.exports = {
|
||||||
})
|
})
|
||||||
.catch(error => reject(error));
|
.catch(error => reject(error));
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
},
|
},
|
||||||
showClaimByShortUrl (name, shortUrl) {
|
showClaimByShortUrl (name, shortUrl) {
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let uri;
|
let uri;
|
||||||
let claimId;
|
let claimId;
|
||||||
// 1. validate the claim id & retrieve the full claim id if needed
|
// 1. validate the claim id & retrieve the full claim id if needed
|
||||||
|
@ -154,7 +152,6 @@ module.exports = {
|
||||||
})
|
})
|
||||||
.catch(error => reject(error));
|
.catch(error => reject(error));
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
},
|
},
|
||||||
showAllClaims (claimName) {
|
showAllClaims (claimName) {
|
||||||
return getAllFreePublicClaims(claimName);
|
return getAllFreePublicClaims(claimName);
|
||||||
|
|
|
@ -70,7 +70,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
getStatsSummary (startDate) {
|
getStatsSummary (startDate) {
|
||||||
logger.debug('retrieving request records');
|
logger.debug('retrieving request records');
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// get the raw Requests data
|
// get the raw Requests data
|
||||||
db.Request
|
db.Request
|
||||||
.findAll({
|
.findAll({
|
||||||
|
@ -140,7 +140,6 @@ module.exports = {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
},
|
},
|
||||||
getTrendingClaims (startDate) {
|
getTrendingClaims (startDate) {
|
||||||
logger.debug('retrieving trending requests');
|
logger.debug('retrieving trending requests');
|
||||||
|
|
|
@ -29,7 +29,7 @@ function orderClaims (claimsListArray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = (claimName) => {
|
module.exports = (claimName) => {
|
||||||
const deferred = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// make a call to the daemon to get the claims list
|
// make a call to the daemon to get the claims list
|
||||||
lbryApi
|
lbryApi
|
||||||
.getClaimsList(claimName)
|
.getClaimsList(claimName)
|
||||||
|
@ -58,5 +58,4 @@ module.exports = (claimName) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ function validateFile(file) {
|
||||||
}
|
}
|
||||||
// validation function that checks to make sure the claim name is not already claimed
|
// validation function that checks to make sure the claim name is not already claimed
|
||||||
function isNameAvailable (name) {
|
function isNameAvailable (name) {
|
||||||
var deferred = new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
// make sure the claim name is still available
|
// make sure the claim name is still available
|
||||||
var xhttp;
|
var xhttp;
|
||||||
xhttp = new XMLHttpRequest();
|
xhttp = new XMLHttpRequest();
|
||||||
|
@ -50,7 +50,6 @@ function isNameAvailable (name) {
|
||||||
};
|
};
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
}
|
}
|
||||||
// validation function that checks to make sure the claim name is valid
|
// validation function that checks to make sure the claim name is valid
|
||||||
function validateClaimName (name) {
|
function validateClaimName (name) {
|
||||||
|
@ -92,7 +91,7 @@ function checkClaimName(name){
|
||||||
}
|
}
|
||||||
// validation function which checks all aspects of the publish submission
|
// validation function which checks all aspects of the publish submission
|
||||||
function validateSubmission(stagedFiles, name){
|
function validateSubmission(stagedFiles, name){
|
||||||
var deferred = new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
// make sure only 1 file was selected
|
// make sure only 1 file was selected
|
||||||
if (!stagedFiles) {
|
if (!stagedFiles) {
|
||||||
reject(new FileError("Please select a file"));
|
reject(new FileError("Please select a file"));
|
||||||
|
@ -119,5 +118,4 @@ function validateSubmission(stagedFiles, name){
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return deferred;
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue