mainly more bug fixes

This commit is contained in:
Jeremy Kauffman 2017-05-11 19:28:43 -04:00
parent 3c325b2f0a
commit c1161fc10b
16 changed files with 101 additions and 132 deletions

View file

@ -9,9 +9,6 @@ import {
import {
selectBalance,
} from 'selectors/wallet'
import {
selectSearchTerm,
} from 'selectors/content'
import {
selectCurrentUriFileInfo,
selectDownloadingByUri,
@ -19,9 +16,6 @@ import {
import {
selectCurrentUriCostInfo,
} from 'selectors/cost_info'
import {
selectCurrentResolvedUriClaimOutpoint,
} from 'selectors/content'
import {
selectClaimsByUri,
} from 'selectors/claims'
@ -31,7 +25,6 @@ import {
import {
doFetchCostInfoForUri,
} from 'actions/cost_info'
import batchActions from 'util/batchActions'
export function doResolveUri(uri) {
return function(dispatch, getState) {
@ -40,7 +33,7 @@ export function doResolveUri(uri) {
data: { uri }
})
return lbry.resolve({ uri }).then((resolutionInfo) => {
lbry.resolve({ uri }).then((resolutionInfo) => {
const {
claim,
certificate,

View file

@ -21,7 +21,15 @@ export function doFetchCostInfoForUri(uri) {
costInfo,
}
})
}).catch(() => {})
}).catch(() => {
dispatch({
type: types.FETCH_COST_INFO_COMPLETED,
data: {
uri,
costInfo: {}
}
})
})
}
}

View file

@ -1,6 +1,4 @@
import * as types from 'constants/action_types'
import lbry from 'lbry'
import lbryio from 'lbryio'
import lbryuri from 'lbryuri'
import lighthouse from 'lighthouse'
import {
@ -12,9 +10,6 @@ import {
import {
selectCurrentPage,
} from 'selectors/app'
import {
selectSearchQuery,
} from 'selectors/search'
export function doSearch(query) {
return function(dispatch, getState) {
@ -27,16 +22,15 @@ export function doSearch(query) {
})
}
if(page != 'search' && query != undefined) {
return dispatch(doNavigate('search', { query: query }))
}
dispatch({
type: types.SEARCH_STARTED,
data: { query }
})
if(page != 'search') {
dispatch(doNavigate('search', { query: query }))
}
lighthouse.search(query).then(results => {
results.forEach(result => {
const uri = lbryuri.build({

View file

@ -5,6 +5,9 @@ import {
import {
doNavigate,
} from 'actions/app'
import {
doResolveUri,
} from 'actions/content'
import {
makeSelectClaimForUri,
makeSelectSourceForUri,
@ -49,7 +52,8 @@ const makeSelect = () => {
}
const perform = (dispatch) => ({
navigate: (path, params) => dispatch(doNavigate(path, params))
navigate: (path, params) => dispatch(doNavigate(path, params)),
resolveUri: (uri) => dispatch(doResolveUri(uri)),
})
export default connect(makeSelect, perform)(FileTile)

View file

@ -22,10 +22,22 @@ class FileTile extends React.Component {
}
componentDidMount() {
const {
isResolvingUri,
resolveUri,
claim,
uri,
} = this.props
this._isMounted = true;
if (this.props.hideOnRemove) {
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate);
}
if(!isResolvingUri && !claim && uri) {
resolveUri(uri)
}
}
componentWillUnmount() {
@ -85,14 +97,14 @@ class FileTile extends React.Component {
description = "Loading..."
} else if (showEmpty === FileTile.SHOW_EMPTY_PUBLISH) {
onClick = () => navigate('/publish')
description = <span className="empty">This location is unclaimed - <Link label="put something here" />!</span>
description = <span className="empty">This location is unclaimed - <span className="button-text">put something here</span>!</span>
} else if (showEmpty === FileTile.SHOW_EMPTY_PENDING) {
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={onClick} className="card__link" className="card__link">
<Link onClick={onClick} 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')) + "')" }}>

View file

@ -64,43 +64,7 @@ const plyr = require('plyr')
class Video extends React.Component {
constructor(props) {
super(props)
// TODO none of this mouse handling stuff seems to actually do anything?
this._controlsHideDelay = 3000 // Note: this needs to be shorter than the built-in delay in Electron, or Electron will hide the controls before us
this._controlsHideTimeout = null
this.state = {}
}
handleMouseMove() {
if (this._controlsTimeout) {
clearTimeout(this._controlsTimeout);
}
if (!this.state.controlsShown) {
this.setState({
controlsShown: true,
});
}
this._controlsTimeout = setTimeout(() => {
if (!this.isMounted) {
return;
}
this.setState({
controlsShown: false,
});
}, this._controlsHideDelay);
}
handleMouseLeave() {
if (this._controlsTimeout) {
clearTimeout(this._controlsTimeout);
}
if (this.state.controlsShown) {
this.setState({
controlsShown: false,
});
}
this.state = { isPlaying: false }
}
onWatchClick() {
@ -141,7 +105,7 @@ class Video extends React.Component {
}
return (
<div onMouseMove={this.handleMouseMove.bind(this)} onMouseLeave={this.handleMouseLeave.bind(this)} className={"video " + this.props.className + (isPlaying && readyToPlay ? " video--active" : " video--hidden")}>{
<div className={"video " + this.props.className + (isPlaying && readyToPlay ? " video--active" : " video--hidden")}>{
isPlaying ?
!readyToPlay ?
<span>this is the world's worst loading screen and we shipped our software with it anyway... <br /><br />{loadStatusMessage}</span> :

View file

@ -3,6 +3,8 @@ import lbryuri from 'lbryuri.js';
import {Icon} from 'component/common.js';
class WunderBar extends React.PureComponent {
static TYPING_TIMEOUT = 800
static propTypes = {
onSearch: React.PropTypes.func.isRequired,
onSubmit: React.PropTypes.func.isRequired
@ -11,6 +13,7 @@ class WunderBar extends React.PureComponent {
constructor(props) {
super(props);
this._userTypingTimer = null;
this._isSearchDispatchPending = false;
this._input = null;
this._stateBeforeSearch = null;
this._resetOnNextBlur = true;
@ -40,15 +43,18 @@ class WunderBar extends React.PureComponent {
this.setState({ address: event.target.value })
this._isSearchDispatchPending = true;
let searchQuery = event.target.value;
this._userTypingTimer = setTimeout(() => {
const hasQuery = searchQuery.length === 0;
this._resetOnNextBlur = hasQuery;
this._isSearchDispatchPending = false;
if (searchQuery) {
this.props.onSearch(searchQuery);
}
}, 800); // 800ms delay, tweak for faster/slower
}, WunderBar.TYPING_TIMEOUT); // 800ms delay, tweak for faster/slower
}
componentWillReceiveProps(nextProps) {
@ -74,14 +80,21 @@ class WunderBar extends React.PureComponent {
}
onBlur() {
let commonState = {isActive: false};
if (this._resetOnNextBlur) {
this.setState(Object.assign({}, this._stateBeforeSearch, commonState));
this._input.value = this.state.address;
if (this._isSearchDispatchPending) {
setTimeout(() => {
this.onBlur();
}, WunderBar.TYPING_TIMEOUT + 1)
} else {
this._resetOnNextBlur = true;
this._stateBeforeSearch = this.state;
this.setState(commonState);
let commonState = {isActive: false};
if (this._resetOnNextBlur) {
this.setState(Object.assign({}, this._stateBeforeSearch, commonState));
this._input.value = this.state.address;
}
else {
this._resetOnNextBlur = true;
this._stateBeforeSearch = this.state;
this.setState(commonState);
}
}
}

View file

@ -6,14 +6,12 @@ import {
selectCurrentUri,
} from 'selectors/app'
import {
selectCurrentUriFileInfo,
selectCurrentUriIsDownloaded,
} from 'selectors/file_info'
import {
selectCurrentUriClaim,
} from 'selectors/claims'
import {
selectCurrentUriFileInfo,
} from 'selectors/file_info'
import {
selectCurrentUriCostInfo,
} from 'selectors/cost_info'

View file

@ -88,6 +88,8 @@ const FilePage = (props) => {
const channelUri = signatureIsValid && hasSignature && channelUriObj.isChannel ? lbryuri.build(channelUriObj, false) : null;
const uriIndicator = <UriIndicator uri={uri} />
// <p>This location is not yet in use. { ' ' }<Link onClick={() => navigate('/publish')} label="Put something here" />.</p>
return (
<main className="main--single-column">
<section className="show-page-media">

View file

@ -14,8 +14,7 @@ import SearchPage from './view'
const select = (state) => ({
isSearching: selectIsSearching(state),
query: selectSearchQuery(state),
results: selectCurrentSearchResults(state),
query: selectSearchQuery(state)
})
const perform = (dispatch) => ({

View file

@ -8,9 +8,6 @@ import {BusyMessage} from 'component/common.js';
class SearchPage extends React.Component{
render() {
console.log('searhc page render');
console.log(this.props);
const isValidUri = (query) => true //FIXME
const {
query,

View file

@ -8,39 +8,22 @@ import {
import {
selectCurrentUri,
} from 'selectors/app'
import {
selectCurrentUriIsDownloaded,
} from 'selectors/file_info'
import {
selectCurrentUriClaim,
} from 'selectors/claims'
import {
selectCurrentUriFileInfo,
} from 'selectors/file_info'
import {
selectCurrentUriCostInfo,
} from 'selectors/cost_info'
import {
makeSelectResolvingUri,
selectCurrentUriIsResolving,
} from 'selectors/content'
import ShowPage from './view'
const makeSelect = () => {
const selectResolvingUri = makeSelectResolvingUri()
const select = (state, props) => ({
claim: selectCurrentUriClaim(state),
uri: selectCurrentUri(state),
isResolvingUri: selectResolvingUri(state, props),
claimType: 'file',
})
return select
}
const select = (state, props) => ({
claim: selectCurrentUriClaim(state),
uri: selectCurrentUri(state),
isResolvingUri: selectCurrentUriIsResolving(state)
})
const perform = (dispatch) => ({
navigate: (path, params) => dispatch(doNavigate(path, params)),
resolveUri: (uri) => dispatch(doResolveUri(uri))
})
export default connect(makeSelect, perform)(ShowPage)
export default connect(select, perform)(ShowPage)

View file

@ -6,12 +6,20 @@ import FilePage from 'page/filePage'
class ShowPage extends React.Component{
componentWillMount() {
this.resolve(this.props)
}
componentWillReceiveProps(nextProps) {
this.resolve(nextProps)
}
resolve(props) {
const {
isResolvingUri,
resolveUri,
claim,
uri,
} = this.props
} = props
if(!isResolvingUri && !claim && uri) {
resolveUri(uri)
@ -20,41 +28,29 @@ class ShowPage extends React.Component{
render() {
const {
claim: {
value: {
stream: {
metadata
} = {},
} = {},
} = {},
navigate,
claim,
uri,
isResolvingUri,
claimType,
} = this.props
const pageTitle = metadata ? metadata.title : uri;
let innerContent = "";
if (isResolvingUri) {
innerContent = <section className="card">
<div className="card__inner">
<div className="card__title-identity"><h1>{pageTitle}</h1></div>
<div className="card__title-identity"><h1>{uri}</h1></div>
</div>
<div className="card__content">
{ isResolvingUri ?
<BusyMessage message="Loading magic decentralized data..." /> :
<p>This location is not yet in use. { ' ' }<Link onClick={() => navigate('/publish')} label="Put something here" />.</p>
}
<BusyMessage message="Loading magic decentralized data..." /> :
</div>
</section>;
}
else if (claimType == "channel") {
innerContent = <ChannelPage title={uri} />
else if (claim && claim.whatever) {
innerContent = "channel"
// innerContent = <ChannelPage title={uri} />
}
else {
innerContent = <FilePage uri={uri} />
else if (claim) {
innerContent = <FilePage />
}
return (

View file

@ -53,6 +53,13 @@ export const selectResolvingUris = createSelector(
(state) => state.resolvingUris || []
)
export const selectCurrentUriIsResolving = createSelector(
selectCurrentUri,
selectResolvingUris,
(uri, resolvingUris) => resolvingUris.indexOf(uri) != -1
)
const selectResolvingUri = (state, props) => {
return selectResolvingUris(state).indexOf(props.uri) != -1
}

View file

@ -1,7 +1,5 @@
import { createSelector } from 'reselect'
import {
selectCurrentParams,
selectDaemonReady,
selectPageTitle,
selectCurrentPage,
selectCurrentUri
@ -10,8 +8,8 @@ import {
export const _selectState = state => state.search || {}
export const selectSearchQuery = createSelector(
selectCurrentParams,
(params) => params.query
_selectState,
(state) => state.query
)
export const selectIsSearching = createSelector(
@ -37,9 +35,10 @@ export const selectCurrentSearchResults = createSelector(
export const selectWunderBarAddress = createSelector(
selectCurrentPage,
selectPageTitle,
selectSearchQuery,
(title, query) => query || title
(page, title, query) => page != "search" ? title : (query ? query : title)
)
export const selectWunderBarIcon = createSelector(

View file

@ -62,12 +62,12 @@ const reducers = redux.combineReducers({
const bulkThunk = createBulkThunkMiddleware()
const middleware = [thunk, bulkThunk]
// if (env === 'development') {
// const logger = createLogger({
// collapsed: true
// });
// middleware.push(logger)
// }
if (env === 'development') {
const logger = createLogger({
collapsed: true
});
middleware.push(logger)
}
const createStoreWithMiddleware = redux.compose(
redux.applyMiddleware(...middleware)