merge plus some bug fixes

This commit is contained in:
Jeremy Kauffman 2017-05-09 16:12:48 -04:00
commit 9c02327b26
9 changed files with 42 additions and 149 deletions

View file

@ -114,7 +114,7 @@ function getPidsForProcessName(name) {
function createWindow () {
win = new BrowserWindow({backgroundColor: '#155B4A', minWidth: 800, minHeight: 600 }) //$color-primary
win.maximize()
// win.webContents.openDevTools();
win.webContents.openDevTools();
win.loadURL(`file://${__dirname}/dist/index.html`)
win.on('closed', () => {
win = null

View file

@ -146,12 +146,6 @@ export function doFetchFeaturedUris() {
uris: featuredUris,
}
})
Object.keys(Uris).forEach((category) => {
Uris[category].forEach((uri) => {
dispatch(doResolveUri(lbryuri.normalize(uri)))
})
})
}
const failure = () => {

View file

@ -5,6 +5,9 @@ import {
import {
doNavigate,
} from 'actions/app'
import {
doResolveUri,
} from 'actions/content'
import {
selectHidePrice,
selectObscureNsfw,
@ -45,6 +48,7 @@ const makeSelect = () => {
const perform = (dispatch) => ({
navigate: (path, params) => dispatch(doNavigate(path, params)),
resolveUri: (uri) => dispatch(doResolveUri(uri)),
})
export default connect(makeSelect, perform)(FileCard)

View file

@ -9,33 +9,21 @@ import UriIndicator from 'component/uriIndicator';
class FileCard extends React.Component {
constructor(props) {
super(props)
this._fileInfoSubscribeId = null
this._isMounted = null
this._metadata = null
this.state = {
showNsfwHelp: false,
isHidden: false,
showNsfwHelp: false
}
}
componentDidMount() {
this._isMounted = true;
if (this.props.hideOnRemove) {
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate);
}
}
const {
resolvingUri,
resolveUri,
claim,
uri,
} = this.props
componentWillUnmount() {
if (this._fileInfoSubscribeId) {
lbry.fileInfoUnsubscribe(this.props.outpoint, this._fileInfoSubscribeId);
}
}
onFileInfoUpdate(fileInfo) {
if (!fileInfo && this._isMounted && this.props.hideOnRemove) {
this.setState({
isHidden: true
});
if(!resolvingUri && !claim && uri) {
resolveUri(uri)
}
}
@ -52,9 +40,6 @@ class FileCard extends React.Component {
}
render() {
if (this.state.isHidden) {
return null;
}
const {
metadata,
@ -73,7 +58,7 @@ class FileCard extends React.Component {
} else if (isResolvingUri) {
description = "Loading..."
} else {
description = <span className="empty">This file is pending confirmation</span>
description = <span className="empty">This file is pending confirmation.</span>
}
return (
@ -94,7 +79,7 @@ class FileCard extends React.Component {
<TruncatedText lines={2}>{description}</TruncatedText>
</div>
</Link>
{this.state.showNsfwHelp && this.state.hovered
{obscureNsfw && this.state.hovered
? <div className='card-overlay'>
<p>
This content is Not Safe For Work.

View file

@ -71,7 +71,7 @@ class FileList extends React.Component {
contentName: fileInfo.name,
channelName: fileInfo.channel_name,
})
content.push(<FileTile key={uri} uri={uri} hidePrice={hidePrices} />)
content.push(<FileTile key={uri} uri={uri} hidePrice={hidePrices} hideOnRemove={true} />)
})
return (
<section>
@ -89,96 +89,4 @@ class FileList extends React.Component {
}
}
// const FileList = React.createClass({
// _sortFunctions: {
// date: function(fileInfos) {
// return fileInfos.slice().reverse();
// },
// title: function(fileInfos) {
// return fileInfos.slice().sort(function(fileInfo1, fileInfo2) {
// const title1 = fileInfo1.metadata ? fileInfo1.metadata.title.toLowerCase() : fileInfo1.name;
// const title2 = fileInfo2.metadata ? fileInfo2.metadata.title.toLowerCase() : fileInfo2.name;
// if (title1 < title2) {
// return -1;
// } else if (title1 > title2) {
// return 1;
// } else {
// return 0;
// }
// });
// },
// filename: function(fileInfos) {
// return fileInfos.slice().sort(function({file_name: fileName1}, {file_name: fileName2}) {
// const fileName1Lower = fileName1.toLowerCase();
// const fileName2Lower = fileName2.toLowerCase();
// if (fileName1Lower < fileName2Lower) {
// return -1;
// } else if (fileName2Lower > fileName1Lower) {
// return 1;
// } else {
// return 0;
// }
// });
// },
// },
// propTypes: {
// fileInfos: React.PropTypes.array.isRequired,
// hidePrices: React.PropTypes.bool,
// },
// getDefaultProps: function() {
// return {
// hidePrices: false,
// };
// },
// getInitialState: function() {
// return {
// sortBy: 'date',
// };
// },
// handleSortChanged: function(event) {
// this.setState({
// sortBy: event.target.value,
// });
// },
// render: function() {
// var content = [],
// seenUris = {};
// console.debug(this.props)
// const fileInfosSorted = this._sortFunctions[this.state.sortBy](this.props.fileInfos);
// for (let {outpoint, name, channel_name, metadata, mime_type, claim_id, has_signature, signature_is_valid} of fileInfosSorted) {
// if (seenUris[name] || !claim_id) {
// continue;
// }
// let streamMetadata;
// if (metadata) {
// streamMetadata = metadata.stream.metadata;
// } else {
// streamMetadata = null;
// }
// const uri = lbryuri.build({contentName: name, channelName: channel_name});
// seenUris[name] = true;
// content.push(<FileTile key={outpoint} uri={uri} hideOnRemove={true} />)
// }
// return (
// <section>
// <span className='sort-section'>
// Sort by { ' ' }
// <FormField type="select" onChange={this.handleSortChanged}>
// <option value="date">Date</option>
// <option value="title">Title</option>
// <option value="filename">File name</option>
// </FormField>
// </span>
// {content}
// </section>
// );
// }
// });
export default FileList

View file

@ -52,4 +52,4 @@ const perform = (dispatch) => ({
navigate: (path, params) => dispatch(doNavigate(path, params))
})
export default connect(makeSelect, perform)(FileTile)
export default connect(makeSelect, perform)(FileTile)

View file

@ -79,40 +79,42 @@ class FileTile extends React.Component {
} else if (isResolvingUri) {
description = "Loading..."
} else {
description = <span className="empty">This file is pending confirmation</span>
description = <span className="empty">This file is pending confirmation.</span>
}
return (
<section className={ 'file-tile card ' + (obscureNsfw ? 'card--obscured ' : '') } onMouseEnter={this.handleMouseOver.bind(this)} onMouseLeave={this.handleMouseOut.bind(this)}>
<Link onClick={() => navigate('/show', { uri })} className="card__link">
<div className="card__inner file-tile__row">
<Link onClick={() => navigate('/show', { uri })} className="card__link" className="card__link">
<div className={"card__inner file-tile__row"}>
<div className="card__media"
style={{ backgroundImage: "url('" + (metadata && metadata.thumbnail ? metadata.thumbnail : lbry.imagePath('default-thumb.svg')) + "')" }}>
</div>
<div className="file-tile__content">
<div className="card__title-identity">
{ !hidePrice ? <span style={{float: "right"}}><FilePrice uri={uri} /></span> : null}
<h5 title={title}><TruncatedText lines={1}>{title}</TruncatedText></h5>
<div className="card__subtitle">
<UriIndicator uri={uri} />
</div>
<div className="card__title-primary">
{ !this.props.hidePrice
? <FilePrice uri={this.props.uri} />
: null}
<div className="meta">{uri}</div>
<h3><TruncatedText lines={1}>{title}</TruncatedText></h3>
</div>
<div className="card__content card__subtext">
<TruncatedText lines={3}>
{description}
{isConfirmed
? metadata.description
: <span className="empty">This file is pending confirmation.</span>}
</TruncatedText>
</div>
</div>
{this.state.showNsfwHelp && this.state.hovered
? <div className='card-overlay'>
<p>
This content is Not Safe For Work.
To view adult content, please change your <Link className="button-text" onClick={() => navigate('/settings')} label="Settings" />.
</p>
</div>
: null}
</div>
</Link>
{this.state.showNsfwHelp
? <div className='card-overlay'>
<p>
This content is Not Safe For Work.
To view adult content, please change your <Link className="button-text" onClick={() => navigate('/settings')} label="Settings" />.
</p>
</div>
: null}
</section>
);
}

View file

@ -2,6 +2,7 @@ import React from 'react';
import lbryio from 'lbryio.js';
import lbryuri from 'lbryuri'
import FileCard from 'component/fileCard';
import {BusyMessage} from 'component/common.js';
import ToolTip from 'component/tooltip.js';
const communityCategoryToolTipText = ('Community Content is a public space where anyone can share content with the ' +
@ -31,7 +32,7 @@ const DiscoverPage = (props) => {
let content
if (fetchingFeaturedUris) content = <div className="empty">Fetching landing content.</div>
if (fetchingFeaturedUris) content = <BusyMessage message="Fetching landing content" />
if (!fetchingFeaturedUris && failed) content = <div className="empty">Failed to load landing content.</div>
if (!fetchingFeaturedUris && !failed) {
content = Object.keys(featuredUris).map(category => {

View file

@ -66,7 +66,6 @@ const SearchPage = (props) => {
const {
query,
} = props
// <SearchResults {...props} />
return (
<main className="main--single-column">
{ isValidUri(query) ?
@ -75,14 +74,14 @@ const SearchPage = (props) => {
Exact URL
<ToolTip label="?" body="This is the resolution of a LBRY URL and not controlled by LBRY Inc." className="tooltip--header" />
</h3>
<FileTile uri={query} showEmpty={true} />
<FileTile uri={lbryuri.normalize(query)} showEmpty={true} />
</section> : '' }
<section className="section-spaced">
<h3 className="card-row__header">
Search Results for {query}
<ToolTip label="?" body="These search results are provided by LBRY, Inc." className="tooltip--header" />
</h3>
<SearchResults {...props} />
</section>
</main>
)