added standard-jsx to eslint and fixed issues

This commit is contained in:
bill bittner 2018-02-21 17:02:57 -08:00
parent 73326a96d3
commit a5e026c1e0
26 changed files with 217 additions and 217 deletions

View file

@ -1,9 +1,10 @@
{ {
"extends": "standard", "extends": ["standard", "standard-jsx"],
"env": { "env": {
"es6": true, "es6": true,
"jest": true, "jest": true,
"node": true "node": true,
"browser": true
}, },
"globals": { "globals": {
"GENTLY": true "GENTLY": true

View file

@ -17,8 +17,7 @@ spee.ch is a single-serving site that reads and publishes images and videos to a
* create your `speechConfig.js` file * create your `speechConfig.js` file
* copy `speechConfig.js.example` and name it `speechConfig.js` * copy `speechConfig.js.example` and name it `speechConfig.js`
* replace the `null` values in the config file with the appropriate values for your environement * replace the `null` values in the config file with the appropriate values for your environement
* to start the server, from your command line run `node serverindex.js` * to start the server, from your command line run `node serverBundle.js`
* To run hot, use `nodemon` instead of `node`
* visit [localhost:3000](http://localhost:3000) * visit [localhost:3000](http://localhost:3000)
## Tests ## Tests

View file

@ -7,31 +7,31 @@ module.exports = {
const userName = channelName.substring(1); const userName = channelName.substring(1);
logger.debug(`authenticateChannelCredentials > channelName: ${channelName} username: ${userName} pass: ${userPassword}`); logger.debug(`authenticateChannelCredentials > channelName: ${channelName} username: ${userName} pass: ${userPassword}`);
db.User db.User
.findOne({where: { userName }}) .findOne({where: { userName }})
.then(user => { .then(user => {
if (!user) { if (!user) {
logger.debug('no user found'); logger.debug('no user found');
resolve(false);
return;
}
return user.comparePassword(userPassword, (passwordErr, isMatch) => {
if (passwordErr) {
logger.error('comparePassword error:', passwordErr);
resolve(false); resolve(false);
return; return;
} }
return user.comparePassword(userPassword, (passwordErr, isMatch) => { if (!isMatch) {
if (passwordErr) { logger.debug('incorrect password');
logger.error('comparePassword error:', passwordErr); resolve(false);
resolve(false); return;
return; }
} logger.debug('...password was a match...');
if (!isMatch) { resolve(true);
logger.debug('incorrect password');
resolve(false);
return;
}
logger.debug('...password was a match...');
resolve(true);
});
})
.catch(error => {
reject(error);
}); });
})
.catch(error => {
reject(error);
});
}); });
}, },
authenticateIfNoUserToken (channelName, channelPassword, user) { authenticateIfNoUserToken (channelName, channelPassword, user) {

View file

@ -10,80 +10,80 @@ module.exports = {
let publishResults, certificateId, channelName; let publishResults, certificateId, channelName;
// publish the file // publish the file
return lbryApi.publishClaim(publishParams) return lbryApi.publishClaim(publishParams)
.then(tx => { .then(tx => {
logger.info(`Successfully published ${publishParams.name} ${fileName}`, tx); logger.info(`Successfully published ${publishParams.name} ${fileName}`, tx);
publishResults = tx; publishResults = tx;
// get the channel information // get the channel information
if (publishParams.channel_name) { if (publishParams.channel_name) {
logger.debug(`this claim was published in channel: ${publishParams.channel_name}`); logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
return db.Channel.findOne({where: {channelName: publishParams.channel_name}}); return db.Channel.findOne({where: {channelName: publishParams.channel_name}});
} else { } else {
logger.debug('this claim was not published in a channel'); logger.debug('this claim was not published in a channel');
return null; return null;
} }
}) })
.then(channel => { .then(channel => {
// set channel information // set channel information
certificateId = null; certificateId = null;
channelName = null; channelName = null;
if (channel) { if (channel) {
certificateId = channel.channelClaimId; certificateId = channel.channelClaimId;
channelName = channel.channelName; channelName = channel.channelName;
} }
logger.debug(`certificateId: ${certificateId}`); logger.debug(`certificateId: ${certificateId}`);
}) })
.then(() => { .then(() => {
// create the File record // create the File record
const fileRecord = { const fileRecord = {
name : publishParams.name, name : publishParams.name,
claimId : publishResults.claim_id, claimId : publishResults.claim_id,
title : publishParams.metadata.title, title : publishParams.metadata.title,
description: publishParams.metadata.description, description: publishParams.metadata.description,
address : publishParams.claim_address, address : publishParams.claim_address,
outpoint : `${publishResults.txid}:${publishResults.nout}`, outpoint : `${publishResults.txid}:${publishResults.nout}`,
height : 0, height : 0,
fileName, fileName,
filePath : publishParams.file_path, filePath : publishParams.file_path,
fileType, fileType,
nsfw : publishParams.metadata.nsfw, nsfw : publishParams.metadata.nsfw,
}; };
// create the Claim record // create the Claim record
const claimRecord = { const claimRecord = {
name : publishParams.name, name : publishParams.name,
claimId : publishResults.claim_id, claimId : publishResults.claim_id,
title : publishParams.metadata.title, title : publishParams.metadata.title,
description: publishParams.metadata.description, description: publishParams.metadata.description,
address : publishParams.claim_address, address : publishParams.claim_address,
thumbnail : publishParams.metadata.thumbnail, thumbnail : publishParams.metadata.thumbnail,
outpoint : `${publishResults.txid}:${publishResults.nout}`, outpoint : `${publishResults.txid}:${publishResults.nout}`,
height : 0, height : 0,
contentType: fileType, contentType: fileType,
nsfw : publishParams.metadata.nsfw, nsfw : publishParams.metadata.nsfw,
amount : publishParams.bid, amount : publishParams.bid,
certificateId, certificateId,
channelName, channelName,
}; };
// upsert criteria // upsert criteria
const upsertCriteria = { const upsertCriteria = {
name : publishParams.name, name : publishParams.name,
claimId: publishResults.claim_id, claimId: publishResults.claim_id,
}; };
// upsert the records // upsert the records
return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]); return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]);
}) })
.then(([file, claim]) => { .then(([file, claim]) => {
logger.debug('File and Claim records successfully created'); logger.debug('File and Claim records successfully created');
return Promise.all([file.setClaim(claim), claim.setFile(file)]); return Promise.all([file.setClaim(claim), claim.setFile(file)]);
}) })
.then(() => { .then(() => {
logger.debug('File and Claim records successfully associated'); logger.debug('File and Claim records successfully associated');
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim; resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
}) })
.catch(error => { .catch(error => {
logger.error('PUBLISH ERROR', error); logger.error('PUBLISH ERROR', error);
publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file
reject(error); reject(error);
}); });
}); });
}, },
checkClaimNameAvailability (name) { checkClaimNameAvailability (name) {

View file

@ -6,11 +6,11 @@ module.exports = function () {
for (let configCategoryKey in config) { for (let configCategoryKey in config) {
if (config.hasOwnProperty(configCategoryKey)) { if (config.hasOwnProperty(configCategoryKey)) {
// get the final variables for each config category // get the final variables for each config category
const configVariables = config[configCategoryKey]; const configVariables = config[configCategoryKey];
for (let configVarKey in configVariables) { for (let configVarKey in configVariables) {
if (configVariables.hasOwnProperty(configVarKey)) { if (configVariables.hasOwnProperty(configVarKey)) {
// print each variable // print each variable
logger.debug(`CONFIG CHECK: ${configCategoryKey}.${configVarKey} === ${configVariables[configVarKey]}`); logger.debug(`CONFIG CHECK: ${configCategoryKey}.${configVarKey} === ${configVariables[configVarKey]}`);
} }
} }

View file

@ -176,15 +176,15 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {
this.findOne({ this.findOne({
where: {name, claimId}, where: {name, claimId},
}) })
.then(result => { .then(result => {
if (!result) { if (!result) {
return resolve(null); return resolve(null);
}; };
resolve(claimId); resolve(claimId);
}) })
.catch(error => { .catch(error => {
reject(error); reject(error);
}); });
}); });
}; };

View file

@ -318,15 +318,15 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {
this.findOne({ this.findOne({
where: {name, claimId}, where: {name, claimId},
}) })
.then(result => { .then(result => {
if (!result) { if (!result) {
return resolve(null); return resolve(null);
}; };
resolve(claimId); resolve(claimId);
}) })
.catch(error => { .catch(error => {
reject(error); reject(error);
}); });
}); });
}; };

View file

@ -40,7 +40,6 @@
"form-data": "^2.3.1", "form-data": "^2.3.1",
"helmet": "^3.8.1", "helmet": "^3.8.1",
"mysql2": "^1.3.5", "mysql2": "^1.3.5",
"nodemon": "^1.11.0",
"passport": "^0.4.0", "passport": "^0.4.0",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"prop-types": "^15.6.0", "prop-types": "^15.6.0",
@ -74,13 +73,14 @@
"chai": "^4.1.2", "chai": "^4.1.2",
"chai-http": "^3.0.0", "chai-http": "^3.0.0",
"css-loader": "^0.28.9", "css-loader": "^0.28.9",
"eslint": "3.19.0", "eslint": "4.18.0",
"eslint-config-standard": "10.2.1", "eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.2.0", "eslint-config-standard-jsx": "^5.0.0",
"eslint-plugin-node": "^4.2.2", "eslint-plugin-import": "^2.8.0",
"eslint-plugin-promise": "3.5.0", "eslint-plugin-node": "^4.2.3",
"eslint-plugin-react": "6.10.3", "eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "3.0.1", "eslint-plugin-react": "^7.6.1",
"eslint-plugin-standard": "^3.0.1",
"husky": "^0.13.4", "husky": "^0.13.4",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"redux-devtools": "^3.4.1", "redux-devtools": "^3.4.1",

View file

@ -8,19 +8,19 @@ function returnUserAndChannelInfo (userInstance) {
userInfo['id'] = userInstance.id; userInfo['id'] = userInstance.id;
userInfo['userName'] = userInstance.userName; userInfo['userName'] = userInstance.userName;
userInstance userInstance
.getChannel() .getChannel()
.then(({channelName, channelClaimId}) => { .then(({channelName, channelClaimId}) => {
userInfo['channelName'] = channelName; userInfo['channelName'] = channelName;
userInfo['channelClaimId'] = channelClaimId; userInfo['channelClaimId'] = channelClaimId;
return db.Certificate.getShortChannelIdFromLongChannelId(channelClaimId, channelName); return db.Certificate.getShortChannelIdFromLongChannelId(channelClaimId, channelName);
}) })
.then(shortChannelId => { .then(shortChannelId => {
userInfo['shortChannelId'] = shortChannelId; userInfo['shortChannelId'] = shortChannelId;
resolve(userInfo); resolve(userInfo);
}) })
.catch(error => { .catch(error => {
reject(error); reject(error);
}); });
}); });
} }
@ -32,34 +32,34 @@ module.exports = new PassportLocalStrategy(
(username, password, done) => { (username, password, done) => {
logger.debug('logging user in'); logger.debug('logging user in');
return db return db
.User .User
.findOne({where: {userName: username}}) .findOne({where: {userName: username}})
.then(user => { .then(user => {
if (!user) { if (!user) {
// logger.debug('no user found'); // logger.debug('no user found');
return done(null, false, {message: 'Incorrect username or password'});
}
user.comparePassword(password, (passwordErr, isMatch) => {
if (passwordErr) {
logger.error('passwordErr:', passwordErr);
return done(null, false, {message: passwordErr});
}
if (!isMatch) {
// logger.debug('incorrect password');
return done(null, false, {message: 'Incorrect username or password'}); return done(null, false, {message: 'Incorrect username or password'});
} }
user.comparePassword(password, (passwordErr, isMatch) => { logger.debug('Password was a match, returning User');
if (passwordErr) { return returnUserAndChannelInfo(user)
logger.error('passwordErr:', passwordErr); .then((userInfo) => {
return done(null, false, {message: passwordErr}); return done(null, userInfo);
} })
if (!isMatch) { .catch(error => {
// logger.debug('incorrect password'); return done(error);
return done(null, false, {message: 'Incorrect username or password'}); });
}
logger.debug('Password was a match, returning User');
return returnUserAndChannelInfo(user)
.then((userInfo) => {
return done(null, userInfo);
})
.catch(error => {
return done(error);
});
});
})
.catch(error => {
return done(error);
}); });
})
.catch(error => {
return done(error);
});
} }
); );

View file

@ -19,7 +19,7 @@ export function getLongClaimId (name, modifier) {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}), }),
body: JSON.stringify(body), body: JSON.stringify(body),
} };
// create url // create url
const url = `/api/claim/long-id`; const url = `/api/claim/long-id`;
// return the request promise // return the request promise

View file

@ -9,11 +9,11 @@ import FourOhFourPage from 'components/FourOhFourPage';
const App = () => { const App = () => {
return ( return (
<Switch> <Switch>
<Route exact path="/" component={PublishPage} /> <Route exact path='/' component={PublishPage} />
<Route exact path="/about" component={AboutPage} /> <Route exact path='/about' component={AboutPage} />
<Route exact path="/login" component={LoginPage} /> <Route exact path='/login' component={LoginPage} />
<Route exact path="/:identifier/:claim" component={ShowPage} /> <Route exact path='/:identifier/:claim' component={ShowPage} />
<Route exact path="/:claim" component={ShowPage} /> <Route exact path='/:claim' component={ShowPage} />
<Route component={FourOhFourPage} /> <Route component={FourOhFourPage} />
</Switch> </Switch>
); );

View file

@ -14,7 +14,7 @@ import App from './app';
const preloadedState = window.__PRELOADED_STATE__ || null; const preloadedState = window.__PRELOADED_STATE__ || null;
// Allow the passed state to be garbage-collected // Allow the passed state to be garbage-collected
delete window.__PRELOADED_STATE__ delete window.__PRELOADED_STATE__;
// create and apply middleware // create and apply middleware
const sagaMiddleware = createSagaMiddleware(); const sagaMiddleware = createSagaMiddleware();

View file

@ -5,23 +5,23 @@ class AboutPage extends React.Component {
render () { render () {
return ( return (
<div> <div>
<NavBar/> <NavBar />
<div className="row row--padded"> <div className='row row--padded'>
<div className="column column--5 column--med-10 align-content-top"> <div className='column column--5 column--med-10 align-content-top'>
<div className="column column--8 column--med-10"> <div className='column column--8 column--med-10'>
<p className="pull-quote">Spee.ch is an open-source project. Please contribute to the existing site, or fork it and make your own.</p> <p className='pull-quote'>Spee.ch is an open-source project. Please contribute to the existing site, or fork it and make your own.</p>
<p><a className="link--primary" target="_blank" href="https://twitter.com/spee_ch">TWITTER</a></p> <p><a className='link--primary' target='_blank' href='https://twitter.com/spee_ch'>TWITTER</a></p>
<p><a className="link--primary" target="_blank" href="https://github.com/lbryio/spee.ch">GITHUB</a></p> <p><a className='link--primary' target='_blank' href='https://github.com/lbryio/spee.ch'>GITHUB</a></p>
<p><a className="link--primary" target="_blank" href="https://discord.gg/YjYbwhS">DISCORD CHANNEL</a></p> <p><a className='link--primary' target='_blank' href='https://discord.gg/YjYbwhS'>DISCORD CHANNEL</a></p>
<p><a className="link--primary" target="_blank" href="https://github.com/lbryio/spee.ch/blob/master/README.md">DOCUMENTATION</a></p> <p><a className='link--primary' target='_blank' href='https://github.com/lbryio/spee.ch/blob/master/README.md'>DOCUMENTATION</a></p>
</div> </div>
</div><div className="column column--5 column--med-10 align-content-top"> </div><div className='column column--5 column--med-10 align-content-top'>
<div className="column column--8 column--med-10"> <div className='column column--8 column--med-10'>
<p>Spee.ch is a media-hosting site that reads from and publishes content to the <a className="link--primary" href="https://lbry.io">LBRY</a> blockchain.</p> <p>Spee.ch is a media-hosting site that reads from and publishes content to the <a className='link--primary' href='https://lbry.io'>LBRY</a> blockchain.</p>
<p>Spee.ch is a hosting service, but with the added benefit that it stores your content on a decentralized network of computers -- the LBRY network. This means that your images are stored in multiple locations without a single point of failure.</p> <p>Spee.ch is a hosting service, but with the added benefit that it stores your content on a decentralized network of computers -- the LBRY network. This means that your images are stored in multiple locations without a single point of failure.</p>
<h3>Contribute</h3> <h3>Contribute</h3>
<p>If you have an idea for your own spee.ch-like site on top of LBRY, fork our <a className="link--primary" href="https://github.com/lbryio/spee.ch">github repo</a> and go to town!</p> <p>If you have an idea for your own spee.ch-like site on top of LBRY, fork our <a className='link--primary' href='https://github.com/lbryio/spee.ch'>github repo</a> and go to town!</p>
<p>If you want to improve spee.ch, join our <a className="link--primary" href="https://discord.gg/YjYbwhS">discord channel</a> or solve one of our <a className="link--primary" href="https://github.com/lbryio/spee.ch/issues">github issues</a>.</p> <p>If you want to improve spee.ch, join our <a className='link--primary' href='https://discord.gg/YjYbwhS'>discord channel</a> or solve one of our <a className='link--primary' href='https://github.com/lbryio/spee.ch/issues'>github issues</a>.</p>
</div> </div>
</div> </div>
</div> </div>

View file

@ -5,7 +5,7 @@ const AssetPreview = ({ name, claimId, fileExt, contentType }) => {
const directSourceLink = `${claimId}/${name}.${fileExt}`; const directSourceLink = `${claimId}/${name}.${fileExt}`;
const showUrlLink = `${claimId}/${name}`; const showUrlLink = `${claimId}/${name}`;
return ( return (
<div className="asset-holder"> <div className='asset-holder'>
<Link to={showUrlLink} > <Link to={showUrlLink} >
{(() => { {(() => {
switch (contentType) { switch (contentType) {
@ -13,16 +13,16 @@ const AssetPreview = ({ name, claimId, fileExt, contentType }) => {
case 'image/jpg': case 'image/jpg':
case 'image/png': case 'image/png':
return ( return (
<img className={'asset-preview'} src={directSourceLink} alt={name}/> <img className={'asset-preview'} src={directSourceLink} alt={name} />
); );
case 'image/gif': case 'image/gif':
return ( return (
<img className={'asset-preview'} src={directSourceLink} alt={name}/> <img className={'asset-preview'} src={directSourceLink} alt={name} />
); );
case 'video/mp4': case 'video/mp4':
return ( return (
<video className={'asset-preview'}> <video className={'asset-preview'}>
<source src={directSourceLink} type={contentType}/> <source src={directSourceLink} type={contentType} />
</video> </video>
); );
default: default:

View file

@ -7,9 +7,9 @@ class ErrorPage extends React.Component {
const { error } = this.props; const { error } = this.props;
return ( return (
<div> <div>
<NavBar/> <NavBar />
<div className="row row--padded"> <div className='row row--padded'>
<p>{error}</p> <p>{error}</p>
</div> </div>
</div> </div>
); );
@ -18,6 +18,6 @@ class ErrorPage extends React.Component {
ErrorPage.propTypes = { ErrorPage.propTypes = {
error: PropTypes.string.isRequired, error: PropTypes.string.isRequired,
} };
export default ErrorPage; export default ErrorPage;

View file

@ -5,10 +5,10 @@ class FourOhForPage extends React.Component {
render () { render () {
return ( return (
<div> <div>
<NavBar/> <NavBar />
<div className="row row--padded"> <div className='row row--padded'>
<h2>404</h2> <h2>404</h2>
<p>That page does not exist</p> <p>That page does not exist</p>
</div> </div>
</div> </div>
); );

View file

@ -6,9 +6,9 @@ class PublishPage extends React.Component {
render () { render () {
return ( return (
<div className={'row row--tall flex-container--column'}> <div className={'row row--tall flex-container--column'}>
<NavBar/> <NavBar />
<div className={'row row--tall row--padded flex-container--column'}> <div className={'row row--tall row--padded flex-container--column'}>
<PublishTool/> <PublishTool />
</div> </div>
</div> </div>
); );

View file

@ -22,6 +22,6 @@ const mapDispatchToProps = dispatch => {
dispatch(updateSelectedChannel(value)); dispatch(updateSelectedChannel(value));
}, },
}; };
} };
export default connect(mapStateToProps, mapDispatchToProps)(View); export default connect(mapStateToProps, mapDispatchToProps)(View);

View file

@ -14,6 +14,6 @@ const mapDispatchToProps = dispatch => {
dispatch(updateMetadata(name, value)); dispatch(updateMetadata(name, value));
}, },
}; };
} };
export default connect(mapStateToProps, mapDispatchToProps)(View); export default connect(mapStateToProps, mapDispatchToProps)(View);

View file

@ -4,7 +4,7 @@ import { updateFileAvailability, updateDisplayAssetError } from 'actions/show';
import { UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states'; import { UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states';
import { checkFileAvailability, triggerClaimGet } from 'api/fileApi'; import { checkFileAvailability, triggerClaimGet } from 'api/fileApi';
function* retrieveFile (action) { function * retrieveFile (action) {
const name = action.data.name; const name = action.data.name;
const claimId = action.data.claimId; const claimId = action.data.claimId;
// see if the file is available // see if the file is available
@ -28,6 +28,6 @@ function* retrieveFile (action) {
yield put(updateFileAvailability(AVAILABLE)); yield put(updateFileAvailability(AVAILABLE));
}; };
export function* watchFileIsRequested () { export function * watchFileIsRequested () {
yield takeLatest(actions.FILE_REQUESTED, retrieveFile); yield takeLatest(actions.FILE_REQUESTED, retrieveFile);
}; };

View file

@ -4,7 +4,7 @@ import { watchNewAssetRequest } from './show_asset';
import { watchNewChannelRequest, watchUpdateChannelClaims } from './show_channel'; import { watchNewChannelRequest, watchUpdateChannelClaims } from './show_channel';
import { watchFileIsRequested } from './file'; import { watchFileIsRequested } from './file';
export default function* rootSaga () { export default function * rootSaga () {
yield all([ yield all([
watchHandleShowPageUri(), watchHandleShowPageUri(),
watchNewAssetRequest(), watchNewAssetRequest(),

View file

@ -4,7 +4,7 @@ import { addRequestToRequestList, onRequestError, addAssetToAssetList } from 'ac
import { getLongClaimId, getShortId, getClaimData } from 'api/assetApi'; import { getLongClaimId, getShortId, getClaimData } from 'api/assetApi';
import { selectShowState } from 'selectors/show'; import { selectShowState } from 'selectors/show';
function* newAssetRequest (action) { function * newAssetRequest (action) {
const { requestId, name, modifier } = action.data; const { requestId, name, modifier } = action.data;
const state = yield select(selectShowState); const state = yield select(selectShowState);
// is this an existing request? // is this an existing request?
@ -52,6 +52,6 @@ function* newAssetRequest (action) {
yield put(onRequestError(null)); yield put(onRequestError(null));
}; };
export function* watchNewAssetRequest () { export function * watchNewAssetRequest () {
yield takeLatest(actions.ASSET_REQUEST_NEW, newAssetRequest); yield takeLatest(actions.ASSET_REQUEST_NEW, newAssetRequest);
}; };

View file

@ -4,7 +4,7 @@ import { addNewChannelToChannelList, addRequestToRequestList, onRequestError, up
import { getChannelClaims, getChannelData } from 'api/channelApi'; import { getChannelClaims, getChannelData } from 'api/channelApi';
import { selectShowState } from 'selectors/show'; import { selectShowState } from 'selectors/show';
function* getNewChannelAndUpdateChannelList (action) { function * getNewChannelAndUpdateChannelList (action) {
const { requestId, channelName, channelId } = action.data; const { requestId, channelName, channelId } = action.data;
const state = yield select(selectShowState); const state = yield select(selectShowState);
// is this an existing request? // is this an existing request?
@ -44,11 +44,11 @@ function* getNewChannelAndUpdateChannelList (action) {
yield put(onRequestError(null)); yield put(onRequestError(null));
} }
export function* watchNewChannelRequest () { export function * watchNewChannelRequest () {
yield takeLatest(actions.CHANNEL_REQUEST_NEW, getNewChannelAndUpdateChannelList); yield takeLatest(actions.CHANNEL_REQUEST_NEW, getNewChannelAndUpdateChannelList);
}; };
function* getNewClaimsAndUpdateChannel (action) { function * getNewClaimsAndUpdateChannel (action) {
const { channelKey, name, longId, page } = action.data; const { channelKey, name, longId, page } = action.data;
let claimsData; let claimsData;
try { try {
@ -59,6 +59,6 @@ function* getNewClaimsAndUpdateChannel (action) {
yield put(updateChannelClaims(channelKey, claimsData)); yield put(updateChannelClaims(channelKey, claimsData));
} }
export function* watchUpdateChannelClaims () { export function * watchUpdateChannelClaims () {
yield takeLatest(actions.CHANNEL_CLAIMS_UPDATE_ASYNC, getNewClaimsAndUpdateChannel); yield takeLatest(actions.CHANNEL_CLAIMS_UPDATE_ASYNC, getNewClaimsAndUpdateChannel);
} }

View file

@ -3,7 +3,7 @@ import * as actions from 'constants/show_action_types';
import { onRequestError, onNewChannelRequest, onNewAssetRequest } from 'actions/show'; import { onRequestError, onNewChannelRequest, onNewAssetRequest } from 'actions/show';
import lbryUri from 'utils/lbryUri'; import lbryUri from 'utils/lbryUri';
function* parseAndUpdateIdentifierAndClaim (modifier, claim) { function * parseAndUpdateIdentifierAndClaim (modifier, claim) {
console.log('parseAndUpdateIdentifierAndClaim'); console.log('parseAndUpdateIdentifierAndClaim');
// this is a request for an asset // this is a request for an asset
// claim will be an asset claim // claim will be an asset claim
@ -21,7 +21,7 @@ function* parseAndUpdateIdentifierAndClaim (modifier, claim) {
}; };
yield put(onNewAssetRequest(claimName, claimId, null, null, extension)); yield put(onNewAssetRequest(claimName, claimId, null, null, extension));
} }
function* parseAndUpdateClaimOnly (claim) { function * parseAndUpdateClaimOnly (claim) {
console.log('parseAndUpdateIdentifierAndClaim'); console.log('parseAndUpdateIdentifierAndClaim');
// this could be a request for an asset or a channel page // this could be a request for an asset or a channel page
// claim could be an asset claim or a channel claim // claim could be an asset claim or a channel claim
@ -46,7 +46,7 @@ function* parseAndUpdateClaimOnly (claim) {
yield put(onNewAssetRequest(claimName, null, null, null, extension)); yield put(onNewAssetRequest(claimName, null, null, null, extension));
} }
function* handleShowPageUri (action) { function * handleShowPageUri (action) {
console.log('handleShowPageUri'); console.log('handleShowPageUri');
const { identifier, claim } = action.data; const { identifier, claim } = action.data;
if (identifier) { if (identifier) {
@ -55,6 +55,6 @@ function* handleShowPageUri (action) {
yield call(parseAndUpdateClaimOnly, claim); yield call(parseAndUpdateClaimOnly, claim);
}; };
export function* watchHandleShowPageUri () { export function * watchHandleShowPageUri () {
yield takeLatest(actions.HANDLE_SHOW_URI, handleShowPageUri); yield takeLatest(actions.HANDLE_SHOW_URI, handleShowPageUri);
}; };

View file

@ -35,4 +35,4 @@ module.exports = {
throw new Error(file.type + ' is not a supported file type. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.'); throw new Error(file.type + ' is not a supported file type. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.');
} }
}, },
} };

View file

@ -8,7 +8,7 @@ module.exports = {
'([^:$#/]*)' + // value (stops at the first separator or end) '([^:$#/]*)' + // value (stops at the first separator or end)
'([:$#]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end) '([:$#]?)([^/]*)' // modifier separator, modifier (stops at the first path separator or end)
); );
const [proto, value, modifierSeperator, modifier] = componentsRegex const [proto, value, modifierSeperator, modifier] = componentsRegex // eslint-disable-line no-unused-vars
.exec(identifier) .exec(identifier)
.map(match => match || null); .map(match => match || null);
@ -56,7 +56,7 @@ module.exports = {
'([^:$#/.]*)' + // name (stops at the first extension) '([^:$#/.]*)' + // name (stops at the first extension)
'([:$#.]?)([^/]*)' // extension separator, extension (stops at the first path separator or end) '([:$#.]?)([^/]*)' // extension separator, extension (stops at the first path separator or end)
); );
const [proto, claimName, extensionSeperator, extension] = componentsRegex const [proto, claimName, extensionSeperator, extension] = componentsRegex // eslint-disable-line no-unused-vars
.exec(name) .exec(name)
.map(match => match || null); .map(match => match || null);