From 3c325b2f0a7242bbd19a5c41fcd770d4633ca788 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Wed, 10 May 2017 20:59:47 -0400 Subject: [PATCH] where's the triggers?! also very broken --- ui/js/actions/app.js | 14 -- ui/js/actions/content.js | 2 +- ui/js/actions/cost_info.js | 9 - ui/js/actions/search.js | 74 +------ ui/js/component/app/index.js | 1 - ui/js/component/app/view.jsx | 6 +- ui/js/component/fileCard/view.jsx | 2 +- ui/js/component/fileListSearch/index.js | 29 +++ ui/js/component/fileListSearch/view.jsx | 70 +++++++ ui/js/component/transactionList/index.js | 25 +++ ui/js/component/transactionList/view.jsx | 65 ++++++ ui/js/component/walletAddress/index.js | 25 +++ ui/js/component/walletAddress/view.jsx | 41 ++++ ui/js/component/walletSend/index.js | 36 ++++ ui/js/component/walletSend/view.jsx | 49 +++++ ui/js/component/wunderbar/index.js | 17 +- ui/js/constants/action_types.js | 2 - ui/js/main.js | 3 - ui/js/page/discover/index.js | 4 + ui/js/page/discover/view.jsx | 49 +++-- ui/js/page/fileListDownloaded/index.js | 4 + ui/js/page/fileListDownloaded/view.jsx | 6 +- ui/js/page/fileListPublished/index.js | 4 + ui/js/page/fileListPublished/view.jsx | 6 +- ui/js/page/search/index.js | 11 +- ui/js/page/search/view.jsx | 101 +++------- ui/js/page/showPage/index.js | 5 +- ui/js/page/wallet/index.js | 43 +--- ui/js/page/wallet/view.jsx | 244 +---------------------- ui/js/reducers/content.js | 1 - ui/js/reducers/search.js | 12 -- ui/js/selectors/app.js | 50 ----- ui/js/selectors/availability.js | 17 +- ui/js/selectors/content.js | 46 +---- ui/js/selectors/cost_info.js | 14 -- ui/js/selectors/file_info.js | 21 -- ui/js/selectors/search.js | 69 +++++-- ui/js/selectors/wallet.js | 26 --- ui/js/store.js | 12 +- ui/js/triggers.js | 102 ---------- 40 files changed, 502 insertions(+), 815 deletions(-) create mode 100644 ui/js/component/fileListSearch/index.js create mode 100644 ui/js/component/fileListSearch/view.jsx create mode 100644 ui/js/component/transactionList/index.js create mode 100644 ui/js/component/transactionList/view.jsx create mode 100644 ui/js/component/walletAddress/index.js create mode 100644 ui/js/component/walletAddress/view.jsx create mode 100644 ui/js/component/walletSend/index.js create mode 100644 ui/js/component/walletSend/view.jsx delete mode 100644 ui/js/triggers.js diff --git a/ui/js/actions/app.js b/ui/js/actions/app.js index c2ec3dcab..14bad12cd 100644 --- a/ui/js/actions/app.js +++ b/ui/js/actions/app.js @@ -28,7 +28,6 @@ export function doNavigate(path, params = {}) { if (params) url = `${url}?${queryStringFromParams(params)}` - console.log('Path: ' + url); dispatch(doChangePath(url)) const state = getState() @@ -201,19 +200,6 @@ export function doAlertError(errorList) { } } -export function doSearch(term) { - return function(dispatch, getState) { - const state = getState() - - dispatch({ - type: types.START_SEARCH, - data: { - searchTerm: term - } - }) - } -} - export function doDaemonReady() { return { type: types.DAEMON_READY diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index fe8dbe0b6..94eed6a10 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -40,7 +40,7 @@ export function doResolveUri(uri) { data: { uri } }) - lbry.resolve({ uri }).then((resolutionInfo) => { + return lbry.resolve({ uri }).then((resolutionInfo) => { const { claim, certificate, diff --git a/ui/js/actions/cost_info.js b/ui/js/actions/cost_info.js index ceab6433b..42d5f61e9 100644 --- a/ui/js/actions/cost_info.js +++ b/ui/js/actions/cost_info.js @@ -25,12 +25,3 @@ export function doFetchCostInfoForUri(uri) { } } -export function doFetchCurrentUriCostInfo() { - return function(dispatch, getState) { - const state = getState() - const uri = selectCurrentUri(state) - - dispatch(doFetchCostInfoForUri(uri)) - } -} - diff --git a/ui/js/actions/search.js b/ui/js/actions/search.js index fd6aee2ad..88206d05e 100644 --- a/ui/js/actions/search.js +++ b/ui/js/actions/search.js @@ -11,90 +11,26 @@ import { } from 'actions/app' import { selectCurrentPage, - selectSearchQuery, } from 'selectors/app' +import { + selectSearchQuery, +} from 'selectors/search' -export function doSearchContent(query) { +export function doSearch(query) { return function(dispatch, getState) { const state = getState() const page = selectCurrentPage(state) - if (!query) { return dispatch({ type: types.SEARCH_CANCELLED, }) } - dispatch({ - type: types.SEARCH_STARTED, - data: { query } - }) - if(page != 'search' && query != undefined) { - dispatch(doNavigate('search', { query: query })) + return dispatch(doNavigate('search', { query: query })) } - lighthouse.search(query).then(results => { - results.forEach(result => { - const uri = lbryuri.build({ - channelName: result.channel_name, - contentName: result.name, - claimId: result.channel_id || result.claim_id, - }) - dispatch(doResolveUri(uri)) - }) - - dispatch({ - type: types.SEARCH_COMPLETED, - data: { - query, - results, - } - }) - }) - } -} - -export function doActivateSearch() { - return function(dispatch, getState) { - const state = getState() - const page = selectCurrentPage(state) - const query = selectSearchQuery(state) - - if(page != 'discover' && query != undefined) dispatch(doNavigate('discover')) - - dispatch({ - type: types.ACTIVATE_SEARCH, - }) - } -} - -export function doDeactivateSearch() { - return { - type: types.DEACTIVATE_SEARCH, - } -} - -export function doSetSearchQuery(query) { - return function(dispatch, getState) { - const state = getState() - - dispatch(doNavigate('/search', { query })) - } -} - -export function doSearch() { - return function(dispatch, getState) { - const state = getState() - const page = selectCurrentPage(state) - const query = selectSearchQuery(state) - - if (!query) { - return dispatch({ - type: types.SEARCH_CANCELLED, - }) - } dispatch({ type: types.SEARCH_STARTED, diff --git a/ui/js/component/app/index.js b/ui/js/component/app/index.js index 95ca69761..a94c0e6f6 100644 --- a/ui/js/component/app/index.js +++ b/ui/js/component/app/index.js @@ -12,7 +12,6 @@ import { doCheckUpgradeAvailable, doOpenModal, doCloseModal, - doSearch, } from 'actions/app' import App from './view' diff --git a/ui/js/component/app/view.jsx b/ui/js/component/app/view.jsx index 92cb7d662..e6162c4dd 100644 --- a/ui/js/component/app/view.jsx +++ b/ui/js/component/app/view.jsx @@ -19,16 +19,12 @@ class App extends React.Component { render() { const { - currentPage, modal, headerLinks, - searchTerm, } = this.props - const searchQuery = (currentPage == 'discover' && searchTerm ? searchTerm : '') return
-
{ alert('header search'); }} - onSubmit={() => { alert('header submit'); }} links={headerLinks} /> +
diff --git a/ui/js/component/fileCard/view.jsx b/ui/js/component/fileCard/view.jsx index 99c95c93b..19e03bc1f 100644 --- a/ui/js/component/fileCard/view.jsx +++ b/ui/js/component/fileCard/view.jsx @@ -63,7 +63,7 @@ class FileCard extends React.Component {
- {metadata && metadata.thumbnail && + {metadata && metadata.thumbnail &&
}
diff --git a/ui/js/component/fileListSearch/index.js b/ui/js/component/fileListSearch/index.js new file mode 100644 index 000000000..ed452052b --- /dev/null +++ b/ui/js/component/fileListSearch/index.js @@ -0,0 +1,29 @@ +import React from 'react' +import { + connect, +} from 'react-redux' +import { + doSearch, +} from 'actions/search' +import { + selectIsSearching, + selectCurrentSearchResults, + selectSearchQuery, +} from 'selectors/search' +import { + doNavigate, +} from 'actions/app' +import FileListSearch from './view' + +const select = (state) => ({ + isSearching: selectIsSearching(state), + query: selectSearchQuery(state), + results: selectCurrentSearchResults(state) +}) + +const perform = (dispatch) => ({ + navigate: (path) => dispatch(doNavigate(path)), + search: (search) => dispatch(doSearch(search)) +}) + +export default connect(select, perform)(FileListSearch) diff --git a/ui/js/component/fileListSearch/view.jsx b/ui/js/component/fileListSearch/view.jsx new file mode 100644 index 000000000..4c9cfc625 --- /dev/null +++ b/ui/js/component/fileListSearch/view.jsx @@ -0,0 +1,70 @@ +import React from 'react'; +import lbry from 'lbry'; +import lbryio from 'lbryio'; +import lbryuri from 'lbryuri'; +import lighthouse from 'lighthouse'; +import FileTile from 'component/fileTile' +import Link from 'component/link' +import {ToolTip} from 'component/tooltip.js'; +import {BusyMessage} from 'component/common.js'; + +const SearchNoResults = (props) => { + const { + navigate, + query, + } = props + + return
+ + No one has checked anything in for {query} yet. { ' ' } + navigate('/publish')} /> + +
; +} + +const FileListSearchResults = (props) => { + const { + results, + } = props + + const rows = [], + seenNames = {}; //fix this when the search API returns claim IDs + + for (let {name, claim, claim_id, channel_name, channel_id, txid, nout} of results) { + const uri = lbryuri.build({ + channelName: channel_name, + contentName: name, + claimId: channel_id || claim_id, + }); + + rows.push( + + ); + } + return ( +
{rows}
+ ); +} + +class FileListSearch extends React.Component{ + componentWillMount() { + this.props.search(this.props.query) + } + + render() { + const { + isSearching, + results + } = this.props + + return ( + isSearching ? + : + (results && results.length) ? + : + + ) + } +} + +export default FileListSearch \ No newline at end of file diff --git a/ui/js/component/transactionList/index.js b/ui/js/component/transactionList/index.js new file mode 100644 index 000000000..7f3dde466 --- /dev/null +++ b/ui/js/component/transactionList/index.js @@ -0,0 +1,25 @@ +import React from 'react' +import { + connect +} from 'react-redux' +import { + doFetchTransactions, +} from 'actions/wallet' +import { + selectBalance, + selectTransactionItems, + selectIsFetchingTransactions, +} from 'selectors/wallet' + +import TransactionList from './view' + +const select = (state) => ({ + fetchingTransactions: selectIsFetchingTransactions(state), + transactionItems: selectTransactionItems(state), +}) + +const perform = (dispatch) => ({ + fetchTransactions: () => dispatch(doFetchTransactions()) +}) + +export default connect(select, perform)(TransactionList) diff --git a/ui/js/component/transactionList/view.jsx b/ui/js/component/transactionList/view.jsx new file mode 100644 index 000000000..49cbf2908 --- /dev/null +++ b/ui/js/component/transactionList/view.jsx @@ -0,0 +1,65 @@ +import React from 'react'; +import { + Address, + BusyMessage, + CreditAmount +} from 'component/common'; + +class TransactionList extends React.Component{ + componentWillMount() { + this.props.fetchTransactions() + } + + render() { + const { + fetchingTransactions, + transactionItems, + } = this.props + + const rows = [] + if (transactionItems.length > 0) { + transactionItems.forEach(function (item) { + rows.push( + + { (item.amount > 0 ? '+' : '' ) + item.amount } + { item.date ? item.date.toLocaleDateString() : (Transaction pending) } + { item.date ? item.date.toLocaleTimeString() : (Transaction pending) } + + {item.id.substr(0, 7)} + + + ); + }); + } + + return ( +
+
+

Transaction History

+
+
+ { fetchingTransactions && } + { !fetchingTransactions && rows.length === 0 ?
You have no transactions.
: '' } + { rows.length > 0 ? + + + + + + + + + + + {rows} + +
AmountDateTimeTransaction
+ : '' + } +
+
+ ) + } +} + +export default TransactionList \ No newline at end of file diff --git a/ui/js/component/walletAddress/index.js b/ui/js/component/walletAddress/index.js new file mode 100644 index 000000000..a62086120 --- /dev/null +++ b/ui/js/component/walletAddress/index.js @@ -0,0 +1,25 @@ +import React from 'react' +import { + connect +} from 'react-redux' +import { + doCheckAddressIsMine, + doGetNewAddress, +} from 'actions/wallet' +import { + selectReceiveAddress, + selectGettingNewAddress +} from 'selectors/wallet' +import WalletPage from './view' + +const select = (state) => ({ + receiveAddress: selectReceiveAddress(state), + gettingNewAddress: selectGettingNewAddress(state), +}) + +const perform = (dispatch) => ({ + checkAddressIsMine: (address) => dispatch(doCheckAddressIsMine(address)), + getNewAddress: () => dispatch(doGetNewAddress()), +}) + +export default connect(select, perform)(WalletPage) \ No newline at end of file diff --git a/ui/js/component/walletAddress/view.jsx b/ui/js/component/walletAddress/view.jsx new file mode 100644 index 000000000..76227786a --- /dev/null +++ b/ui/js/component/walletAddress/view.jsx @@ -0,0 +1,41 @@ +import React from 'react'; +import Link from 'component/link'; +import { + Address +} from 'component/common'; + +class WalletAddress extends React.Component { + componentWillMount() { + this.props.checkAddressIsMine(this.props.receiveAddress) + } + + render() { + const { + receiveAddress, + getNewAddress, + gettingNewAddress, + } = this.props + + return ( +
+
+

Wallet Address

+
+
+
+
+
+ +
+
+
+

Other LBRY users may send credits to you by entering this address on the "Send" page.

+

You can generate a new address at any time, and any previous addresses will continue to work. Using multiple addresses can be helpful for keeping track of incoming payments from multiple sources.

+
+
+
+ ); + } +} + +export default WalletAddress \ No newline at end of file diff --git a/ui/js/component/walletSend/index.js b/ui/js/component/walletSend/index.js new file mode 100644 index 000000000..eb65ca2b4 --- /dev/null +++ b/ui/js/component/walletSend/index.js @@ -0,0 +1,36 @@ +import React from 'react' +import { + connect +} from 'react-redux' +import { + doCloseModal, +} from 'actions/app' +import { + doSendDraftTransaction, + doSetDraftTransactionAmount, + doSetDraftTransactionAddress, +} from 'actions/wallet' +import { + selectCurrentModal, +} from 'selectors/app' +import { + selectDraftTransactionAmount, + selectDraftTransactionAddress, +} from 'selectors/wallet' + +import WalletSend from './view' + +const select = (state) => ({ + modal: selectCurrentModal(state), + address: selectDraftTransactionAddress(state), + amount: selectDraftTransactionAmount(state), +}) + +const perform = (dispatch) => ({ + closeModal: () => dispatch(doCloseModal()), + sendToAddress: () => dispatch(doSendDraftTransaction()), + setAmount: (event) => dispatch(doSetDraftTransactionAmount(event.target.value)), + setAddress: (event) => dispatch(doSetDraftTransactionAddress(event.target.value)), +}) + +export default connect(select, perform)(WalletSend) diff --git a/ui/js/component/walletSend/view.jsx b/ui/js/component/walletSend/view.jsx new file mode 100644 index 000000000..60e7c6126 --- /dev/null +++ b/ui/js/component/walletSend/view.jsx @@ -0,0 +1,49 @@ +import React from 'react'; +import Link from 'component/link'; +import Modal from 'component/modal'; +import { + FormRow +} from 'component/form'; + +const WalletSend = (props) => { + const { + sendToAddress, + closeModal, + modal, + setAmount, + setAddress, + amount, + address, + } = props + + return ( +
+
+
+

Send Credits

+
+
+ +
+
+ +
+
+ 0.0) || !address} /> + +
+
+ {modal == 'insufficientBalance' && + Insufficient balance: after this transaction you would have less than 1 LBC in your wallet. + } + {modal == 'transactionSuccessful' && + Your transaction was successfully placed in the queue. + } + {modal == 'transactionFailed' && + Something went wrong: + } +
+ ) +} + +export default WalletSend \ No newline at end of file diff --git a/ui/js/component/wunderbar/index.js b/ui/js/component/wunderbar/index.js index 6976f7933..9e597220b 100644 --- a/ui/js/component/wunderbar/index.js +++ b/ui/js/component/wunderbar/index.js @@ -6,15 +6,13 @@ import lbryuri from 'lbryuri.js' import { selectWunderBarAddress, selectWunderBarIcon -} from 'selectors/app' +} from 'selectors/search' +import { + doSearch, +} from 'actions/search' import { doNavigate, } from 'actions/app' -import { - doSearchContent, - doActivateSearch, - doDeactivateSearch, -} from 'actions/search' import Wunderbar from './view' const select = (state) => ({ @@ -23,12 +21,7 @@ const select = (state) => ({ }) const perform = (dispatch) => ({ - // navigate: (path) => dispatch(doNavigate(path)), - // onSearch: (query) => dispatch(doSearchContent(query)), - // onSubmit: (query) => dispatch(doSearchContent(query)), - // activateSearch: () => dispatch(doActivateSearch()), - // deactivateSearch: () => setTimeout(() => { dispatch(doDeactivateSearch()) }, 50), - onSearch: (query) => dispatch(doNavigate('/search', { query })), + onSearch: (query) => dispatch(doSearch(query)), onSubmit: (query) => dispatch(doNavigate('/show', { uri: lbryuri.normalize(query) } )) }) diff --git a/ui/js/constants/action_types.js b/ui/js/constants/action_types.js index 42a4eba3f..70a75e69f 100644 --- a/ui/js/constants/action_types.js +++ b/ui/js/constants/action_types.js @@ -60,5 +60,3 @@ export const FETCH_MY_CLAIMS_COMPLETED = 'FETCH_MY_CLAIMS_COMPLETED' export const SEARCH_STARTED = 'SEARCH_STARTED' export const SEARCH_COMPLETED = 'SEARCH_COMPLETED' export const SEARCH_CANCELLED = 'SEARCH_CANCELLED' -export const ACTIVATE_SEARCH = 'ACTIVATE_SEARCH' -export const DEACTIVATE_SEARCH = 'DEACTIVATE_SEARCH' diff --git a/ui/js/main.js b/ui/js/main.js index dcee11d57..6f37050aa 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -9,7 +9,6 @@ import SnackBar from './component/snack-bar.js'; import {AuthOverlay} from './component/auth.js'; import { Provider } from 'react-redux'; import store from 'store.js'; -import { runTriggers } from 'triggers' import { doDaemonReady, doChangePath, @@ -41,8 +40,6 @@ ipcRenderer.on('open-uri-requested', (event, uri) => { }); const initialState = app.store.getState(); -app.store.subscribe(runTriggers); -runTriggers(); var init = function() { diff --git a/ui/js/page/discover/index.js b/ui/js/page/discover/index.js index 47713f5e7..a79f98a68 100644 --- a/ui/js/page/discover/index.js +++ b/ui/js/page/discover/index.js @@ -2,6 +2,9 @@ import React from 'react' import { connect } from 'react-redux' +import { + doFetchFeaturedUris, +} from 'actions/content' import { selectFeaturedUris, selectFetchingFeaturedUris, @@ -14,6 +17,7 @@ const select = (state) => ({ }) const perform = (dispatch) => ({ + fetchFeaturedUris: () => dispatch(doFetchFeaturedUris()) }) export default connect(select, perform)(DiscoverPage) diff --git a/ui/js/page/discover/view.jsx b/ui/js/page/discover/view.jsx index 6bcab8adb..024f0d913 100644 --- a/ui/js/page/discover/view.jsx +++ b/ui/js/page/discover/view.jsx @@ -23,28 +23,37 @@ const FeaturedCategory = (props) => {
} -const DiscoverPage = (props) => { - const { - featuredUris, - fetchingFeaturedUris, - } = props - const failed = Object.keys(featuredUris).length === 0 - - let content - - if (fetchingFeaturedUris) content = - if (!fetchingFeaturedUris && failed) content =
Failed to load landing content.
- if (!fetchingFeaturedUris && !failed) { - content = Object.keys(featuredUris).map(category => { - return featuredUris[category].length ? - : - ''; - }) +class DiscoverPage extends React.Component{ + componentWillMount() { + this.props.fetchFeaturedUris() } - return ( -
{content}
- ) + render() { + const { + featuredUris, + fetchingFeaturedUris, + } = this.props + + let content + + if (fetchingFeaturedUris) { + content = + } else { + if (typeof featuredUris === "object") { + content = Object.keys(featuredUris).map(category => { + return featuredUris[category].length ? + : + ''; + }) + } else if (featuredUris !== undefined) { + content =
Failed to load landing content.
+ } + } + + return ( +
{content}
+ ) + } } export default DiscoverPage; \ No newline at end of file diff --git a/ui/js/page/fileListDownloaded/index.js b/ui/js/page/fileListDownloaded/index.js index 6d92a1867..7ab01ab9c 100644 --- a/ui/js/page/fileListDownloaded/index.js +++ b/ui/js/page/fileListDownloaded/index.js @@ -2,6 +2,9 @@ import React from 'react' import { connect } from 'react-redux' +import { + doFetchDownloadedContent, +} from 'actions/content' import { selectFetchingDownloadedContent, } from 'selectors/content' @@ -20,6 +23,7 @@ const select = (state) => ({ const perform = (dispatch) => ({ navigate: (path) => dispatch(doNavigate(path)), + fetchFileListDownloaded: () => dispatch(doFetchDownloadedContent()), }) export default connect(select, perform)(FileListDownloaded) diff --git a/ui/js/page/fileListDownloaded/view.jsx b/ui/js/page/fileListDownloaded/view.jsx index 48d85b864..8006828dd 100644 --- a/ui/js/page/fileListDownloaded/view.jsx +++ b/ui/js/page/fileListDownloaded/view.jsx @@ -11,6 +11,10 @@ import FileList from 'component/fileList' import SubHeader from 'component/subHeader' class FileListDownloaded extends React.Component { + componentWillMount() { + this.props.fetchFileListDownloaded() + } + render() { const { downloadedContent, @@ -28,7 +32,7 @@ class FileListDownloaded extends React.Component { } return ( -
+
{content}
diff --git a/ui/js/page/fileListPublished/index.js b/ui/js/page/fileListPublished/index.js index f2b5c78f5..22f2b8736 100644 --- a/ui/js/page/fileListPublished/index.js +++ b/ui/js/page/fileListPublished/index.js @@ -2,6 +2,9 @@ import React from 'react' import { connect } from 'react-redux' +import { + doFetchPublishedContent, +} from 'actions/content' import { selectFetchingPublishedContent, } from 'selectors/content' @@ -20,6 +23,7 @@ const select = (state) => ({ const perform = (dispatch) => ({ navigate: (path) => dispatch(doNavigate(path)), + fetchFileListPublished: () => dispatch(doFetchPublishedContent()), }) export default connect(select, perform)(FileListPublished) diff --git a/ui/js/page/fileListPublished/view.jsx b/ui/js/page/fileListPublished/view.jsx index 686e7e314..704a76cff 100644 --- a/ui/js/page/fileListPublished/view.jsx +++ b/ui/js/page/fileListPublished/view.jsx @@ -11,6 +11,10 @@ import FileList from 'component/fileList' import SubHeader from 'component/subHeader' class FileListPublished extends React.Component { + componentWillMount() { + this.props.fetchFileListPublished() + } + componentDidUpdate() { if(this.props.publishedContent.length > 0) this._requestPublishReward() } @@ -49,7 +53,7 @@ class FileListPublished extends React.Component { } return ( -
+
{content}
diff --git a/ui/js/page/search/index.js b/ui/js/page/search/index.js index 4d80c95f5..01a75d6d8 100644 --- a/ui/js/page/search/index.js +++ b/ui/js/page/search/index.js @@ -2,17 +2,11 @@ import React from 'react' import { connect, } from 'react-redux' -import { - doSearchContent, -} from 'actions/search' import { selectIsSearching, - selectCurrentSearchResults, - selectSearchActivated, -} from 'selectors/search' -import { selectSearchQuery, -} from 'selectors/app' + selectCurrentSearchResults, +} from 'selectors/search' import { doNavigate, } from 'actions/app' @@ -22,7 +16,6 @@ const select = (state) => ({ isSearching: selectIsSearching(state), query: selectSearchQuery(state), results: selectCurrentSearchResults(state), - searchActive: selectSearchActivated(state), }) const perform = (dispatch) => ({ diff --git a/ui/js/page/search/view.jsx b/ui/js/page/search/view.jsx index d23abb333..50b580c79 100644 --- a/ui/js/page/search/view.jsx +++ b/ui/js/page/search/view.jsx @@ -1,89 +1,40 @@ import React from 'react'; -import lbry from 'lbry'; -import lbryio from 'lbryio'; import lbryuri from 'lbryuri'; -import lighthouse from 'lighthouse'; import FileTile from 'component/fileTile' -import Link from 'component/link' +import FileListSearch from 'component/fileListSearch' import {ToolTip} from 'component/tooltip.js'; import {BusyMessage} from 'component/common.js'; -const SearchNoResults = (props) => { - const { - navigate, - query, - } = props - return
- - No one has checked anything in for {query} yet. { ' ' } - navigate('/publish')} /> - -
; -} +class SearchPage extends React.Component{ + render() { + console.log('searhc page render'); + console.log(this.props); -const SearchResultList = (props) => { - const { - results, - } = props + const isValidUri = (query) => true //FIXME + const { + query, + } = this.props - const rows = [], - seenNames = {}; //fix this when the search API returns claim IDs - - for (let {name, claim, claim_id, channel_name, channel_id, txid, nout} of results) { - const uri = lbryuri.build({ - channelName: channel_name, - contentName: name, - claimId: channel_id || claim_id, - }); - - rows.push( - - ); - } - return ( -
{rows}
- ); -} - -const SearchResults = (props) => { - const { - isSearching, - results - } = props - - return ( - isSearching ? - : - (results && results.length) ? - : - - ) -} - -const SearchPage = (props) => { - const isValidUri = (query) => true - const { - query, - } = props - return ( -
- { isValidUri(query) ? + return ( +
+ { isValidUri(query) ? +
+

+ Exact URL +

+ +
: '' }

- Exact URL - + Search Results for {query}

- -
: '' } -
-

- Search Results for {query} - -

- -
-
- ) + + +
+ ) + } } export default SearchPage; diff --git a/ui/js/page/showPage/index.js b/ui/js/page/showPage/index.js index 86dbe394d..e1aa5f810 100644 --- a/ui/js/page/showPage/index.js +++ b/ui/js/page/showPage/index.js @@ -5,9 +5,6 @@ import { import { doResolveUri, } from 'actions/content' -import { - doNavigate, -} from 'actions/app' import { selectCurrentUri, } from 'selectors/app' @@ -43,7 +40,7 @@ const makeSelect = () => { const perform = (dispatch) => ({ navigate: (path, params) => dispatch(doNavigate(path, params)), - resolveUri: (uri) => dispatch(doResolveUri(uri)), + resolveUri: (uri) => dispatch(doResolveUri(uri)) }) export default connect(makeSelect, perform)(ShowPage) diff --git a/ui/js/page/wallet/index.js b/ui/js/page/wallet/index.js index ac9095938..b99acfc6b 100644 --- a/ui/js/page/wallet/index.js +++ b/ui/js/page/wallet/index.js @@ -3,51 +3,16 @@ import { connect } from 'react-redux' import { - doCloseModal, -} from 'actions/app' -import { - doGetNewAddress, - doCheckAddressIsMine, - doSendDraftTransaction, - doSetDraftTransactionAmount, - doSetDraftTransactionAddress, -} from 'actions/wallet' -import { - selectCurrentPage, - selectCurrentModal, + selectCurrentPage } from 'selectors/app' import { - selectBalance, - selectTransactions, - selectTransactionItems, - selectIsFetchingTransactions, - selectReceiveAddress, - selectGettingNewAddress, - selectDraftTransactionAmount, - selectDraftTransactionAddress, + selectBalance } from 'selectors/wallet' import WalletPage from './view' const select = (state) => ({ currentPage: selectCurrentPage(state), - balance: selectBalance(state), - transactions: selectTransactions(state), - fetchingTransactions: selectIsFetchingTransactions(state), - transactionItems: selectTransactionItems(state), - receiveAddress: selectReceiveAddress(state), - gettingNewAddress: selectGettingNewAddress(state), - modal: selectCurrentModal(state), - address: selectDraftTransactionAddress(state), - amount: selectDraftTransactionAmount(state), + balance: selectBalance(state) }) -const perform = (dispatch) => ({ - closeModal: () => dispatch(doCloseModal()), - getNewAddress: () => dispatch(doGetNewAddress()), - checkAddressIsMine: (address) => dispatch(doCheckAddressIsMine(address)), - sendToAddress: () => dispatch(doSendDraftTransaction()), - setAmount: (event) => dispatch(doSetDraftTransactionAmount(event.target.value)), - setAddress: (event) => dispatch(doSetDraftTransactionAddress(event.target.value)), -}) - -export default connect(select, perform)(WalletPage) +export default connect(select, null)(WalletPage) diff --git a/ui/js/page/wallet/view.jsx b/ui/js/page/wallet/view.jsx index c9ef2f71c..4093d003f 100644 --- a/ui/js/page/wallet/view.jsx +++ b/ui/js/page/wallet/view.jsx @@ -1,245 +1,13 @@ import React from 'react'; -import lbry from 'lbry.js'; -import Link from 'component/link'; -import Modal from 'component/modal'; import SubHeader from 'component/subHeader' +import TransactionList from 'component/transactionList' +import WalletAddress from 'component/walletAddress' +import WalletSend from 'component/walletSend' + import { - FormField, - FormRow -} from 'component/form'; -import { - Address, - BusyMessage, CreditAmount } from 'component/common'; -class AddressSection extends React.Component { - componentWillMount() { - this.props.checkAddressIsMine(this.props.receiveAddress) - } - - render() { - const { - receiveAddress, - getNewAddress, - gettingNewAddress, - } = this.props - - return ( -
-
-

Wallet Address

-
-
-
-
-
- -
-
-
-

Other LBRY users may send credits to you by entering this address on the "Send" page.

-

You can generate a new address at any time, and any previous addresses will continue to work. Using multiple addresses can be helpful for keeping track of incoming payments from multiple sources.

-
-
-
- ); - } -} - -const SendToAddressSection = (props) => { - const { - sendToAddress, - closeModal, - modal, - setAmount, - setAddress, - amount, - address, - } = props - - return ( -
-
-
-

Send Credits

-
-
- -
-
- -
-
- 0.0) || !address} /> - -
-
- {modal == 'insufficientBalance' && - Insufficient balance: after this transaction you would have less than 1 LBC in your wallet. - } - {modal == 'transactionSuccessful' && - Your transaction was successfully placed in the queue. - } - {modal == 'transactionFailed' && - Something went wrong: - } -
- ) -} - -// var SendToAddressSection = React.createClass({ -// handleSubmit: function(event) { -// if (typeof event !== 'undefined') { -// event.preventDefault(); -// } - -// if ((this.state.balance - this.state.amount) < 1) -// { -// this.setState({ -// modal: 'insufficientBalance', -// }); -// return; -// } - -// this.setState({ -// results: "", -// }); - -// lbry.sendToAddress(this.state.amount, this.state.address, (results) => { -// if(results === true) -// { -// this.setState({ -// results: "Your transaction was successfully placed in the queue.", -// }); -// } -// else -// { -// this.setState({ -// results: "Something went wrong: " + results -// }); -// } -// }, (error) => { -// this.setState({ -// results: "Something went wrong: " + error.message -// }) -// }); -// }, -// closeModal: function() { -// this.setState({ -// modal: null, -// }); -// }, -// getInitialState: function() { -// return { -// address: "", -// amount: 0.0, -// balance: , -// results: "", -// } -// }, -// componentWillMount: function() { -// lbry.getBalance((results) => { -// this.setState({ -// balance: results, -// }); -// }); -// }, -// setAmount: function(event) { -// this.setState({ -// amount: parseFloat(event.target.value), -// }) -// }, -// setAddress: function(event) { -// this.setState({ -// address: event.target.value, -// }) -// }, -// render: function() { -// return ( -//
-//
-//
-//

Send Credits

-//
-//
-// -//
-//
-// -//
-//
-// 0.0) || this.state.address == ""} /> -// -//
-// { -// this.state.results ? -//
-//

Results

-// {this.state.results} -//
: '' -// } -//
-// -// Insufficient balance: after this transaction you would have less than 1 LBC in your wallet. -// -//
-// ); -// } -// }); - -const TransactionList = (props) => { - const { - fetchingTransactions, - transactionItems, - } = props - - const rows = [] - if (transactionItems.length > 0) { - transactionItems.forEach(function(item) { - rows.push( - - { (item.amount > 0 ? '+' : '' ) + item.amount } - { item.date ? item.date.toLocaleDateString() : (Transaction pending) } - { item.date ? item.date.toLocaleTimeString() : (Transaction pending) } - - {item.id.substr(0, 7)} - - - ); - }); - } - - return ( -
-
-

Transaction History

-
-
- { fetchingTransactions ? : '' } - { !fetchingTransactions && rows.length === 0 ?
You have no transactions.
: '' } - { rows.length > 0 ? - - - - - - - - - - - {rows} - -
AmountDateTimeTransaction
- : '' - } -
-
- ) -} - const WalletPage = (props) => { const { balance, @@ -258,8 +26,8 @@ const WalletPage = (props) => { { currentPage === 'wallet' ? : '' } - { currentPage === 'send' ? : '' } - { currentPage === 'receive' ? : '' } + { currentPage === 'send' ? : '' } + { currentPage === 'receive' ? : '' }
) } diff --git a/ui/js/reducers/content.js b/ui/js/reducers/content.js index 4f9d54594..8fee4c234 100644 --- a/ui/js/reducers/content.js +++ b/ui/js/reducers/content.js @@ -16,7 +16,6 @@ reducers[types.FETCH_FEATURED_CONTENT_COMPLETED] = function(state, action) { success } = action.data - return Object.assign({}, state, { fetchingFeaturedContent: false, fetchingFeaturedContentFailed: !success, diff --git a/ui/js/reducers/search.js b/ui/js/reducers/search.js index 24cd757f6..50a38966f 100644 --- a/ui/js/reducers/search.js +++ b/ui/js/reducers/search.js @@ -41,18 +41,6 @@ reducers[types.SEARCH_CANCELLED] = function(state, action) { }) } -reducers[types.ACTIVATE_SEARCH] = function(state, action) { - return Object.assign({}, state, { - activated: true, - }) -} - -reducers[types.DEACTIVATE_SEARCH] = function(state, action) { - return Object.assign({}, state, { - activated: false, - }) -} - export default function reducer(state = defaultState, action) { const handler = reducers[action.type]; if (handler) return handler(state, action); diff --git a/ui/js/selectors/app.js b/ui/js/selectors/app.js index 6337dd4e0..7692adae7 100644 --- a/ui/js/selectors/app.js +++ b/ui/js/selectors/app.js @@ -31,11 +31,6 @@ export const selectCurrentParams = createSelector( } ) -export const selectSearchQuery = createSelector( - selectCurrentParams, - (params) => params.query -) - export const selectCurrentUri = createSelector( selectCurrentPath, (path) => { @@ -93,51 +88,6 @@ export const selectPageTitle = createSelector( } ) -export const selectWunderBarAddress = createSelector( - selectPageTitle, - selectSearchQuery, - (title, query) => query || title -) - -export const selectWunderBarIcon = createSelector( - selectCurrentPage, - selectCurrentUri, - (page, uri) => { - switch (page) { - case 'search': - return 'icon-search' - case 'settings': - return 'icon-gear' - case 'help': - return 'icon-question' - case 'report': - return 'icon-file' - case 'downloaded': - return 'icon-folder' - case 'published': - return 'icon-folder' - case 'start': - return 'icon-file' - case 'rewards': - return 'icon-bank' - case 'wallet': - case 'send': - case 'receive': - return 'icon-bank' - case 'show': - return 'icon-file' - case 'publish': - return 'icon-upload' - case 'developer': - return 'icon-file' - case 'developer': - return 'icon-code' - case 'discover': - return 'icon-home' - } - } -) - export const selectPlatform = createSelector( _selectState, (state) => state.platform diff --git a/ui/js/selectors/availability.js b/ui/js/selectors/availability.js index 7aeaa6330..0eaebc318 100644 --- a/ui/js/selectors/availability.js +++ b/ui/js/selectors/availability.js @@ -56,19 +56,4 @@ export const selectAvailabilityForCurrentUri = createSelector( selectCurrentUri, selectAvailabilityByUri, (uri, byUri) => byUri[uri] -) - -export const shouldFetchCurrentUriAvailability = createSelector( - selectDaemonReady, - selectCurrentPage, - selectFetchingAvailabilityForCurrentUri, - selectAvailabilityForCurrentUri, - (daemonReady, page, fetching, availability) => { - if (!daemonReady) return false - if (page != 'show') return false - if (fetching) return false - if (availability) return false - - return true - } -) +) \ No newline at end of file diff --git a/ui/js/selectors/content.js b/ui/js/selectors/content.js index 05e9f2ef9..68df29b0f 100644 --- a/ui/js/selectors/content.js +++ b/ui/js/selectors/content.js @@ -9,7 +9,7 @@ export const _selectState = state => state.content || {} export const selectFeaturedUris = createSelector( _selectState, - (state) => state.featuredUris || {} + (state) => state.featuredUris ) export const selectFetchingFeaturedUris = createSelector( @@ -17,21 +17,6 @@ export const selectFetchingFeaturedUris = createSelector( (state) => !!state.fetchingFeaturedContent ) -export const shouldFetchFeaturedUris = createSelector( - selectDaemonReady, - selectCurrentPage, - selectFetchingFeaturedUris, - selectFeaturedUris, - (daemonReady, page, fetching, byCategory) => { - if (!daemonReady) return false - if (page != 'discover') return false - if (fetching) return false - if (Object.keys(byCategory).length != 0) return false - - return true - } -) - export const selectFetchingFileInfos = createSelector( _selectState, (state) => state.fetchingFileInfos || {} @@ -52,21 +37,6 @@ export const selectDownloadedContentFileInfos = createSelector( (downloadedContent) => downloadedContent.fileInfos || [] ) -export const shouldFetchDownloadedContent = createSelector( - selectDaemonReady, - selectCurrentPage, - selectFetchingDownloadedContent, - selectDownloadedContent, - (daemonReady, page, fetching, content) => { - if (!daemonReady) return false - if (page != 'downloaded') return false - if (fetching) return false - if (Object.keys(content).length != 0) return false - - return true - } -) - export const selectFetchingPublishedContent = createSelector( _selectState, (state) => !!state.fetchingPublishedContent @@ -77,20 +47,6 @@ export const selectPublishedContent = createSelector( (state) => state.publishedContent || {} ) -export const shouldFetchPublishedContent = createSelector( - selectDaemonReady, - selectCurrentPage, - selectFetchingPublishedContent, - selectPublishedContent, - (daemonReady, page, fetching, content) => { - if (!daemonReady) return false - if (page != 'published') return false - if (fetching) return false - if (Object.keys(content).length != 0) return false - - return true - } -) export const selectResolvingUris = createSelector( _selectState, diff --git a/ui/js/selectors/cost_info.js b/ui/js/selectors/cost_info.js index d250aaf19..f48fa3438 100644 --- a/ui/js/selectors/cost_info.js +++ b/ui/js/selectors/cost_info.js @@ -28,20 +28,6 @@ export const selectFetchingCurrentUriCostInfo = createSelector( (uri, byUri) => !!byUri[uri] ) -export const shouldFetchCurrentUriCostInfo = createSelector( - selectCurrentPage, - selectCurrentUri, - selectFetchingCurrentUriCostInfo, - selectCurrentUriCostInfo, - (page, uri, fetching, costInfo) => { - if (page != 'show') return false - if (fetching) return false - if (Object.keys(costInfo).length != 0) return false - - return true - } -) - const selectCostInfoForUri = (state, props) => { return selectAllCostInfoByUri(state)[props.uri] } diff --git a/ui/js/selectors/file_info.js b/ui/js/selectors/file_info.js index cbe5b665c..b41d5ae49 100644 --- a/ui/js/selectors/file_info.js +++ b/ui/js/selectors/file_info.js @@ -65,27 +65,6 @@ export const selectCurrentUriIsDownloaded = createSelector( } ) -export const shouldFetchCurrentUriFileInfo = createSelector( - selectCurrentPage, - selectCurrentUri, - selectFetchingCurrentUriFileInfo, - selectCurrentUriFileInfo, - (page, uri, fetching, fileInfo) => { - console.log('should fetch?'); - console.log(page); - console.log(uri); - console.log(fetching); - - if (page != 'show') return false - if (fetching) return false - if (fileInfo != undefined) return false - - console.log('fetch!'); - - return true - } -) - const selectFileInfoForUri = (state, props) => { return selectAllFileInfoByUri(state)[props.uri] } diff --git a/ui/js/selectors/search.js b/ui/js/selectors/search.js index 0b838376f..1a4e6ffde 100644 --- a/ui/js/selectors/search.js +++ b/ui/js/selectors/search.js @@ -2,11 +2,18 @@ import { createSelector } from 'reselect' import { selectCurrentParams, selectDaemonReady, - selectSearchQuery, + selectPageTitle, + selectCurrentPage, + selectCurrentUri } from 'selectors/app' export const _selectState = state => state.search || {} +export const selectSearchQuery = createSelector( + selectCurrentParams, + (params) => params.query +) + export const selectIsSearching = createSelector( _selectState, (state) => !!state.searching @@ -25,25 +32,51 @@ export const selectSearchResultsByQuery = createSelector( export const selectCurrentSearchResults = createSelector( selectSearchQuery, selectSearchResultsByQuery, - (query, byQuery) => byQuery[query] || [] + (query, byQuery) => byQuery[query] ) -export const selectSearchActivated = createSelector( - _selectState, - (state) => !!state.activated -) -export const shouldSearch = createSelector( - selectDaemonReady, +export const selectWunderBarAddress = createSelector( + selectPageTitle, selectSearchQuery, - selectIsSearching, - selectSearchResultsByQuery, - (daemonReady, query, isSearching, resultsByQuery) => { - if (!daemonReady) return false - if (!query) return false - if (isSearching) return false - if (Object.keys(resultsByQuery).indexOf(query) != -1) return false - - return true - } + (title, query) => query || title ) + +export const selectWunderBarIcon = createSelector( + selectCurrentPage, + selectCurrentUri, + (page, uri) => { + switch (page) { + case 'search': + return 'icon-search' + case 'settings': + return 'icon-gear' + case 'help': + return 'icon-question' + case 'report': + return 'icon-file' + case 'downloaded': + return 'icon-folder' + case 'published': + return 'icon-folder' + case 'start': + return 'icon-file' + case 'rewards': + return 'icon-bank' + case 'wallet': + case 'send': + case 'receive': + return 'icon-bank' + case 'show': + return 'icon-file' + case 'publish': + return 'icon-upload' + case 'developer': + return 'icon-file' + case 'developer': + return 'icon-code' + case 'discover': + return 'icon-home' + } + } +) \ No newline at end of file diff --git a/ui/js/selectors/wallet.js b/ui/js/selectors/wallet.js index eedaffa3e..d56bf4d94 100644 --- a/ui/js/selectors/wallet.js +++ b/ui/js/selectors/wallet.js @@ -43,19 +43,6 @@ export const selectIsFetchingTransactions = createSelector( (state) => state.fetchingTransactions ) -export const shouldFetchTransactions = createSelector( - selectCurrentPage, - selectTransactions, - selectIsFetchingTransactions, - (page, transactions, fetching) => { - if (page != 'wallet') return false - if (fetching) return false - if (transactions.length != 0) return false - - return true - } -) - export const selectReceiveAddress = createSelector( _selectState, (state) => state.receiveAddress @@ -66,19 +53,6 @@ export const selectGettingNewAddress = createSelector( (state) => state.gettingNewAddress ) -export const shouldGetReceiveAddress = createSelector( - selectReceiveAddress, - selectGettingNewAddress, - selectDaemonReady, - (address, fetching, daemonReady) => { - if (!daemonReady) return false - if (fetching) return false - if (address) return false - - return true - } -) - export const shouldCheckAddressIsMine = createSelector( _selectState, selectCurrentPage, diff --git a/ui/js/store.js b/ui/js/store.js index 462c6a5d0..b824cbe7d 100644 --- a/ui/js/store.js +++ b/ui/js/store.js @@ -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) diff --git a/ui/js/triggers.js b/ui/js/triggers.js deleted file mode 100644 index c8201ee66..000000000 --- a/ui/js/triggers.js +++ /dev/null @@ -1,102 +0,0 @@ -import { - shouldFetchTransactions, - shouldGetReceiveAddress, -} from 'selectors/wallet' -import { - shouldFetchFeaturedUris, - shouldFetchDownloadedContent, - shouldFetchPublishedContent, -} from 'selectors/content' -import { - shouldFetchCurrentUriFileInfo, -} from 'selectors/file_info' -import { - shouldFetchCurrentUriCostInfo, -} from 'selectors/cost_info' -import { - shouldFetchCurrentUriAvailability, -} from 'selectors/availability' -import { - doFetchTransactions, - doGetNewAddress, -} from 'actions/wallet' -import { - doFetchFeaturedUris, - doFetchDownloadedContent, - doFetchPublishedContent, -} from 'actions/content' -import { - doFetchCurrentUriFileInfo, -} from 'actions/file_info' -import { - doFetchCurrentUriCostInfo, -} from 'actions/cost_info' -import { - doFetchCurrentUriAvailability, -} from 'actions/availability' -import { - shouldSearch, -} from 'selectors/search' -import { - doSearch, -} from 'actions/search' - -const triggers = [] - -triggers.push({ - selector: shouldFetchTransactions, - action: doFetchTransactions, -}) - -triggers.push({ - selector: shouldGetReceiveAddress, - action: doGetNewAddress -}) - -triggers.push({ - selector: shouldFetchFeaturedUris, - action: doFetchFeaturedUris, -}) - -triggers.push({ - selector: shouldFetchDownloadedContent, - action: doFetchDownloadedContent, -}) - -triggers.push({ - selector: shouldFetchPublishedContent, - action: doFetchPublishedContent, -}) - -triggers.push({ - selector: shouldFetchCurrentUriFileInfo, - action: doFetchCurrentUriFileInfo, -}) - -triggers.push({ - selector: shouldFetchCurrentUriCostInfo, - action: doFetchCurrentUriCostInfo, -}) - -triggers.push({ - selector: shouldFetchCurrentUriAvailability, - action: doFetchCurrentUriAvailability, -}) - -triggers.push({ - selector: shouldSearch, - action: doSearch, -}) - -const runTriggers = function() { - triggers.forEach(function(trigger) { - const state = app.store.getState(); - const should = trigger.selector(state) - if (trigger.selector(state)) app.store.dispatch(trigger.action()) - }); -} - -module.exports = { - triggers: triggers, - runTriggers: runTriggers -}