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