From 3fadcad51a8ba043edc574d9fa8be8f77f92bbf8 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 12 Mar 2019 15:53:55 -0400 Subject: [PATCH] upgrade lbry{inc,-redux} --- package.json | 4 +- src/ui/component/common/file-exporter.jsx | 13 ++--- src/ui/component/fileActions/index.js | 7 +-- src/ui/component/fileCard/index.js | 6 +-- src/ui/component/fileDownloadLink/index.js | 2 +- src/ui/component/filePrice/index.js | 6 +-- src/ui/component/fileTile/index.js | 2 +- src/ui/component/fileViewer/index.js | 3 +- src/ui/index.jsx | 10 +--- src/ui/modal/modalRouter/index.js | 14 +++--- src/ui/page/discover/index.js | 9 +++- src/ui/page/file/index.js | 3 +- src/ui/page/show/index.js | 2 +- src/ui/redux/actions/content.js | 3 +- src/ui/redux/reducers/content.js | 57 ---------------------- src/ui/store.js | 11 +++-- webpack.base.config.js | 7 ++- yarn.lock | 17 ++----- 18 files changed, 51 insertions(+), 125 deletions(-) diff --git a/package.json b/package.json index 6d526508f..27da97bdf 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "hast-util-sanitize": "^1.1.2", "keytar": "^4.3.0", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#406e1970b9d5594faf0407100c9bbed45d904cdf", - "lbryinc": "lbryio/lbryinc#2334ad53e82c22d6291899785d5292347008f2a9", + "lbry-redux": "lbryio/lbry-redux#71dda665759ead555fef0bccef3a0ae653cb4509", + "lbryinc": "lbryio/lbryinc#b54e90f3d497f0d91b3bb94dab063f0696775169", "localforage": "^1.7.1", "mammoth": "^1.4.6", "mime": "^2.3.1", diff --git a/src/ui/component/common/file-exporter.jsx b/src/ui/component/common/file-exporter.jsx index c8e5d135d..cc1b8c1d8 100644 --- a/src/ui/component/common/file-exporter.jsx +++ b/src/ui/component/common/file-exporter.jsx @@ -4,16 +4,11 @@ import * as ICONS from 'constants/icons'; import React from 'react'; import Button from 'component/button'; import parseData from 'util/parse-data'; -/* eslint-disable no-redeclare */ -// @if TARGET='app' -// $FlowFixMe import { remote } from 'electron'; +import path from 'path'; +// @if TARGET='app' +import fs from 'fs'; // @endif -// @if TARGET='web' -// $FlowFixMe -import { remote } from 'web/stubs'; -// @endif -/* eslint-enable no-redeclare */ type Props = { data: Array, @@ -34,8 +29,6 @@ class FileExporter extends React.PureComponent { this.handleButtonClick = this.handleButtonClick.bind(this); } - handleButtonClick: () => void; - handleFileCreation(filename: string, data: any) { const { onFileCreated } = this.props; // @if TARGET='app' diff --git a/src/ui/component/fileActions/index.js b/src/ui/component/fileActions/index.js index 94a9ead66..64e878190 100644 --- a/src/ui/component/fileActions/index.js +++ b/src/ui/component/fileActions/index.js @@ -1,9 +1,6 @@ import { connect } from 'react-redux'; -import { - makeSelectCostInfoForUri, - makeSelectFileInfoForUri, - makeSelectClaimIsMine, -} from 'lbry-redux'; +import { makeSelectFileInfoForUri, makeSelectClaimIsMine } from 'lbry-redux'; +import { makeSelectCostInfoForUri } from 'lbryinc'; import { doOpenModal } from 'redux/actions/app'; import FileActions from './view'; diff --git a/src/ui/component/fileCard/index.js b/src/ui/component/fileCard/index.js index 5f31fff7b..c45ec7fea 100644 --- a/src/ui/component/fileCard/index.js +++ b/src/ui/component/fileCard/index.js @@ -8,11 +8,9 @@ import { makeSelectClaimIsMine, makeSelectClaimIsPending, } from 'lbry-redux'; +import { selectRewardContentClaimIds } from 'lbryinc'; import { doNavigate } from 'redux/actions/navigation'; -import { - selectRewardContentClaimIds, - makeSelectContentPositionForUri, -} from 'redux/selectors/content'; +import { makeSelectContentPositionForUri } from 'redux/selectors/content'; import { selectShowNsfw } from 'redux/selectors/settings'; import { makeSelectIsSubscribed, makeSelectIsNew } from 'redux/selectors/subscriptions'; import { doClearContentHistoryUri } from 'redux/actions/content'; diff --git a/src/ui/component/fileDownloadLink/index.js b/src/ui/component/fileDownloadLink/index.js index 6d4334e01..50519c69b 100644 --- a/src/ui/component/fileDownloadLink/index.js +++ b/src/ui/component/fileDownloadLink/index.js @@ -3,9 +3,9 @@ import { makeSelectFileInfoForUri, makeSelectDownloadingForUri, makeSelectLoadingForUri, - makeSelectCostInfoForUri, makeSelectClaimForUri, } from 'lbry-redux'; +import { makeSelectCostInfoForUri } from 'lbryinc'; import { doOpenFileInShell } from 'redux/actions/file'; import { doPurchaseUri, doStartDownload, doSetPlayingUri } from 'redux/actions/content'; import FileDownloadLink from './view'; diff --git a/src/ui/component/filePrice/index.js b/src/ui/component/filePrice/index.js index 688644316..26aa6a00a 100644 --- a/src/ui/component/filePrice/index.js +++ b/src/ui/component/filePrice/index.js @@ -1,10 +1,10 @@ import { connect } from 'react-redux'; +import { makeSelectClaimForUri } from 'lbry-redux'; import { - doFetchCostInfoForUri, makeSelectCostInfoForUri, + doFetchCostInfoForUri, makeSelectFetchingCostInfoForUri, - makeSelectClaimForUri, -} from 'lbry-redux'; +} from 'lbryinc'; import FilePrice from './view'; const select = (state, props) => ({ diff --git a/src/ui/component/fileTile/index.js b/src/ui/component/fileTile/index.js index e924bc377..145145586 100644 --- a/src/ui/component/fileTile/index.js +++ b/src/ui/component/fileTile/index.js @@ -7,10 +7,10 @@ import { makeSelectIsUriResolving, makeSelectClaimIsMine, } from 'lbry-redux'; +import { selectRewardContentClaimIds } from 'lbryinc'; import { selectShowNsfw } from 'redux/selectors/settings'; import { doNavigate } from 'redux/actions/navigation'; import { doClearPublish, doUpdatePublishForm } from 'redux/actions/publish'; -import { selectRewardContentClaimIds } from 'redux/selectors/content'; import { makeSelectIsSubscribed, makeSelectIsNew } from 'redux/selectors/subscriptions'; import FileTile from './view'; diff --git a/src/ui/component/fileViewer/index.js b/src/ui/component/fileViewer/index.js index de544872e..3860d889b 100644 --- a/src/ui/component/fileViewer/index.js +++ b/src/ui/component/fileViewer/index.js @@ -4,11 +4,10 @@ import { doChangeVolume } from 'redux/actions/app'; import { selectVolume } from 'redux/selectors/app'; import { doPlayUri, doSetPlayingUri, savePosition } from 'redux/actions/content'; import { doNavigate } from 'redux/actions/navigation'; -import { doClaimEligiblePurchaseRewards } from 'lbryinc'; +import { doClaimEligiblePurchaseRewards, makeSelectCostInfoForUri } from 'lbryinc'; import { makeSelectMetadataForUri, makeSelectContentTypeForUri, - makeSelectCostInfoForUri, makeSelectClaimForUri, makeSelectFileInfoForUri, makeSelectLoadingForUri, diff --git a/src/ui/index.jsx b/src/ui/index.jsx index 1024ba20d..ffd7ee610 100644 --- a/src/ui/index.jsx +++ b/src/ui/index.jsx @@ -18,16 +18,10 @@ import { doOpenModal, doHideModal, } from 'redux/actions/app'; -import { - Lbry, - doToast, - doBlackListedOutpointsSubscribe, - isURIValid, - setSearchApi, -} from 'lbry-redux'; +import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux'; import { doNavigate, doHistoryBack, doHistoryForward } from 'redux/actions/navigation'; import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings'; -import { doAuthenticate, Lbryio, rewards } from 'lbryinc'; +import { doAuthenticate, Lbryio, rewards, doBlackListedOutpointsSubscribe } from 'lbryinc'; import 'scss/all.scss'; import store from 'store'; import pjson from 'package.json'; diff --git a/src/ui/modal/modalRouter/index.js b/src/ui/modal/modalRouter/index.js index 673316518..4865bf898 100644 --- a/src/ui/modal/modalRouter/index.js +++ b/src/ui/modal/modalRouter/index.js @@ -1,14 +1,12 @@ import { connect } from 'react-redux'; import * as settings from 'constants/settings'; -import { - selectCostForCurrentPageUri, - selectBalance, - selectCurrentPage, - selectError, - doToast, -} from 'lbry-redux'; +import { selectBalance, selectCurrentPage, selectError, doToast } from 'lbry-redux'; import { makeSelectClientSetting } from 'redux/selectors/settings'; -import { selectUser, selectUserIsVerificationCandidate } from 'lbryinc'; +import { + selectUser, + selectUserIsVerificationCandidate, + selectCostForCurrentPageUri, +} from 'lbryinc'; import { selectModal } from 'redux/selectors/app'; import { doOpenModal } from 'redux/actions/app'; import ModalRouter from './view'; diff --git a/src/ui/page/discover/index.js b/src/ui/page/discover/index.js index a01dd7b2f..99f92641c 100644 --- a/src/ui/page/discover/index.js +++ b/src/ui/page/discover/index.js @@ -1,6 +1,11 @@ import { connect } from 'react-redux'; -import { selectFeaturedUris, selectFetchingFeaturedUris, doFetchFeaturedUris } from 'lbry-redux'; -import { doFetchRewardedContent, doRewardList } from 'lbryinc'; +import { + doFetchRewardedContent, + doRewardList, + selectFeaturedUris, + doFetchFeaturedUris, + selectFetchingFeaturedUris, +} from 'lbryinc'; import DiscoverPage from './view'; const select = state => ({ diff --git a/src/ui/page/file/index.js b/src/ui/page/file/index.js index be8c75689..ebaa384dd 100644 --- a/src/ui/page/file/index.js +++ b/src/ui/page/file/index.js @@ -7,15 +7,14 @@ import { doSetClientSetting } from 'redux/actions/settings'; import { doSetContentHistoryItem } from 'redux/actions/content'; import { doFetchFileInfo, - doFetchCostInfoForUri, makeSelectClaimIsMine, - makeSelectCostInfoForUri, makeSelectFileInfoForUri, makeSelectClaimForUri, makeSelectContentTypeForUri, makeSelectMetadataForUri, makeSelectChannelForClaimUri, } from 'lbry-redux'; +import { makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc'; import { selectShowNsfw, makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { doPrepareEdit } from 'redux/actions/publish'; diff --git a/src/ui/page/show/index.js b/src/ui/page/show/index.js index 8bdfed38d..0e7bd852c 100644 --- a/src/ui/page/show/index.js +++ b/src/ui/page/show/index.js @@ -5,8 +5,8 @@ import { makeSelectClaimForUri, makeSelectIsUriResolving, makeSelectTotalPagesForChannel, - selectBlackListedOutpoints, } from 'lbry-redux'; +import { selectBlackListedOutpoints } from 'lbryinc'; import ShowPage from './view'; const select = (state, props) => ({ diff --git a/src/ui/redux/actions/content.js b/src/ui/redux/actions/content.js index c35f36b19..7843c213b 100644 --- a/src/ui/redux/actions/content.js +++ b/src/ui/redux/actions/content.js @@ -16,7 +16,6 @@ import { Lbry, Lbryapi, buildURI, - makeSelectCostInfoForUri, makeSelectFileInfoForUri, selectFileInfosByOutpoint, selectDownloadingByOutpoint, @@ -26,6 +25,8 @@ import { creditsToString, doError, } from 'lbry-redux'; +import { makeSelectCostInfoForUri } from 'lbryinc'; + import { makeSelectClientSetting, selectosNotificationsEnabled } from 'redux/selectors/settings'; import setBadge from 'util/set-badge'; import analytics from 'analytics'; diff --git a/src/ui/redux/reducers/content.js b/src/ui/redux/reducers/content.js index 0b96be940..8ebbacbb0 100644 --- a/src/ui/redux/reducers/content.js +++ b/src/ui/redux/reducers/content.js @@ -3,68 +3,11 @@ import * as ACTIONS from 'constants/action_types'; const reducers = {}; const defaultState = { playingUri: null, - rewardedContentClaimIds: [], channelClaimCounts: {}, positions: {}, history: [], }; -reducers[ACTIONS.FETCH_FEATURED_CONTENT_STARTED] = state => - Object.assign({}, state, { - fetchingFeaturedContent: true, - }); - -reducers[ACTIONS.FETCH_FEATURED_CONTENT_COMPLETED] = (state, action) => { - const { uris, success } = action.data; - - return Object.assign({}, state, { - fetchingFeaturedContent: false, - fetchingFeaturedContentFailed: !success, - featuredUris: uris, - }); -}; - -reducers[ACTIONS.FETCH_REWARD_CONTENT_COMPLETED] = (state, action) => { - const { claimIds } = action.data; - - return Object.assign({}, state, { - rewardedContentClaimIds: claimIds, - }); -}; - -reducers[ACTIONS.RESOLVE_URIS_STARTED] = (state, action) => { - const { uris } = action.data; - - const oldResolving = state.resolvingUris || []; - const newResolving = Object.assign([], oldResolving); - - uris.forEach(uri => { - if (!newResolving.includes(uri)) { - newResolving.push(uri); - } - }); - - return Object.assign({}, state, { - resolvingUris: newResolving, - }); -}; - -reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state, action) => { - const { resolveInfo } = action.data; - const channelClaimCounts = Object.assign({}, state.channelClaimCounts); - - Object.entries(resolveInfo).forEach(([uri, { certificate, claimsInChannel }]) => { - if (certificate && !Number.isNaN(claimsInChannel)) { - channelClaimCounts[uri] = claimsInChannel; - } - }); - - return Object.assign({}, state, { - channelClaimCounts, - resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri]), - }); -}; - reducers[ACTIONS.SET_PLAYING_URI] = (state, action) => Object.assign({}, state, { playingUri: action.data.uri, diff --git a/src/ui/store.js b/src/ui/store.js index 15c45f6db..d86b51555 100644 --- a/src/ui/store.js +++ b/src/ui/store.js @@ -3,16 +3,20 @@ import availabilityReducer from 'redux/reducers/availability'; import contentReducer from 'redux/reducers/content'; import { claimsReducer, - costInfoReducer, fileInfoReducer, searchReducer, walletReducer, notificationsReducer, - blacklistReducer, } from 'lbry-redux'; +import { + userReducer, + rewardsReducer, + costInfoReducer, + blacklistReducer, + homepageReducer, +} from 'lbryinc'; import navigationReducer from 'redux/reducers/navigation'; import settingsReducer from 'redux/reducers/settings'; -import { userReducer, rewardsReducer } from 'lbryinc'; import shapeShiftReducer from 'redux/reducers/shape_shift'; import subscriptionsReducer from 'redux/reducers/subscriptions'; import publishReducer from 'redux/reducers/publish'; @@ -69,6 +73,7 @@ const reducers = combineReducers({ publish: publishReducer, notifications: notificationsReducer, blacklist: blacklistReducer, + homepage: homepageReducer, }); const bulkThunk = createBulkThunkMiddleware(); diff --git a/webpack.base.config.js b/webpack.base.config.js index 2cfa160c5..e5beea7a8 100644 --- a/webpack.base.config.js +++ b/webpack.base.config.js @@ -3,7 +3,9 @@ const merge = require('webpack-merge'); const { DefinePlugin, ProvidePlugin } = require('webpack'); const { getIfUtils, removeEmpty } = require('webpack-config-utils'); -const { ifProduction } = getIfUtils(process.env.NODE_ENV || 'development'); +const NODE_ENV = process.env.NODE_ENV || 'development'; + +const { ifProduction } = getIfUtils(NODE_ENV); const UI_ROOT = path.resolve(__dirname, 'src/ui/'); const STATIC_ROOT = path.resolve(__dirname, 'static/'); @@ -76,8 +78,9 @@ const baseConfig = { }), new DefinePlugin({ __static: `"${path.join(__dirname, 'static').replace(/\\/g, '\\\\')}"`, - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), + 'process.env.NODE_ENV': JSON.stringify(NODE_ENV), 'process.env.SDK_API_URL': JSON.stringify(process.env.SDK_API_URL), + 'process.env.LBRY_API_URL': JSON.stringify(process.env.LBRY_API_URL), }), ], }; diff --git a/yarn.lock b/yarn.lock index ca3721944..2c3517553 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5962,28 +5962,19 @@ lazy-val@^1.0.3, lazy-val@^1.0.4: tar-stream "^1.6.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#406e1970b9d5594faf0407100c9bbed45d904cdf: +lbry-redux@lbryio/lbry-redux#71dda665759ead555fef0bccef3a0ae653cb4509: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/406e1970b9d5594faf0407100c9bbed45d904cdf" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/71dda665759ead555fef0bccef3a0ae653cb4509" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0" uuid "^3.3.2" -lbry-redux@lbryio/lbry-redux#76d8bbef9640bf8ea5c4f45550e55b77d3944ee3: +lbryinc@lbryio/lbryinc#b54e90f3d497f0d91b3bb94dab063f0696775169: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/76d8bbef9640bf8ea5c4f45550e55b77d3944ee3" - dependencies: - proxy-polyfill "0.1.6" - reselect "^3.0.0" - uuid "^3.3.2" - -lbryinc@lbryio/lbryinc#2334ad53e82c22d6291899785d5292347008f2a9: - version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/2334ad53e82c22d6291899785d5292347008f2a9" + resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/b54e90f3d497f0d91b3bb94dab063f0696775169" dependencies: bluebird "^3.5.1" - lbry-redux lbryio/lbry-redux#76d8bbef9640bf8ea5c4f45550e55b77d3944ee3 reselect "^3.0.0" lcid@^1.0.0: -- 2.45.3