From 121e4b215ff60f0cf2ac10b8f62bdcfc47aff21d Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Fri, 2 Nov 2018 14:33:00 -0400 Subject: [PATCH] Rc fixes (#2085) * fix: channel button color on dark mode * fix: disabled primary button in dark mode * fix: show pending publishes immediately * update lbry-redux * remove duplicate import * use lbry colors for 'new' badge * fix: don't filter transactions in recent transactions * fix: remove unread subscriptions on un-subscribe * handle edits and new files the same for pending publishes * don't loop over transactions if we don't have to * bump lbry-redux --- .eslintrc.json | 3 +- package.json | 2 +- .../component/transactionList/view.jsx | 5 ++- src/renderer/page/fileListPublished/index.js | 7 +++- src/renderer/page/fileListPublished/view.jsx | 1 - src/renderer/redux/actions/publish.js | 38 +++++++++++++++---- src/renderer/redux/reducers/subscriptions.js | 7 +++- src/renderer/scss/all.scss | 2 +- src/renderer/scss/component/_badge.scss | 4 +- src/renderer/scss/component/_button.scss | 3 +- src/renderer/scss/themes/_dark.scss | 19 ++++++---- src/renderer/types/claim.js | 12 ++++++ yarn.lock | 8 ++-- 13 files changed, 81 insertions(+), 30 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6a992f8bf..a8f285504 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,6 +43,7 @@ "class-methods-use-this": 0, "jsx-a11y/interactive-supports-focus": 0, "jsx-a11y/click-events-have-key-events": 0, - "consistent-return": 0 + "consistent-return": 0, + "flowtype/space-after-type-colon": [ 2, "always", { "allowLineBreak": true } ] } } diff --git a/package.json b/package.json index 0787f6304..10da3eb23 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "formik": "^0.10.4", "hast-util-sanitize": "^1.1.2", "keytar": "^4.2.1", - "lbry-redux": "lbryio/lbry-redux#f193d38c61ea061679ebc7b4ca139a0e9c95ef8a", + "lbry-redux": "lbryio/lbry-redux#dd26422a86a37b5a492dc0702269ad6fc04ecdd7", "lbryinc": "lbryio/lbryinc#7a458ea13ceceffa0191e73139f94e5c953f22b1", "localforage": "^1.7.1", "mammoth": "^1.4.6", diff --git a/src/renderer/component/transactionList/view.jsx b/src/renderer/component/transactionList/view.jsx index 4aaf9ae27..c5f043d89 100644 --- a/src/renderer/component/transactionList/view.jsx +++ b/src/renderer/component/transactionList/view.jsx @@ -66,7 +66,10 @@ class TransactionList extends React.PureComponent { render() { const { emptyMessage, rewards, transactions, slim, filterSetting } = this.props; - const transactionList = transactions.filter(this.filterTransaction); + + // The shorter "recent transactions" list shouldn't be filtered + const transactionList = slim ? transactions : transactions.filter(this.filterTransaction); + // Flow offers little support for Object.values() typing. // https://github.com/facebook/flow/issues/2221 // $FlowFixMe diff --git a/src/renderer/page/fileListPublished/index.js b/src/renderer/page/fileListPublished/index.js index d3b4e90fd..1826fb78d 100644 --- a/src/renderer/page/fileListPublished/index.js +++ b/src/renderer/page/fileListPublished/index.js @@ -1,6 +1,9 @@ import { connect } from 'react-redux'; -import { selectPendingPublishes } from 'redux/selectors/publish'; -import { selectIsFetchingClaimListMine, selectFileListPublishedSort, selectMyClaimsWithoutChannels } from 'lbry-redux'; +import { + selectIsFetchingClaimListMine, + selectFileListPublishedSort, + selectMyClaimsWithoutChannels, +} from 'lbry-redux'; import { doNavigate } from 'redux/actions/navigation'; import { doCheckPendingPublishes } from 'redux/actions/publish'; import FileListPublished from './view'; diff --git a/src/renderer/page/fileListPublished/view.jsx b/src/renderer/page/fileListPublished/view.jsx index 338da3b60..478a79999 100644 --- a/src/renderer/page/fileListPublished/view.jsx +++ b/src/renderer/page/fileListPublished/view.jsx @@ -22,7 +22,6 @@ class FileListPublished extends React.PureComponent { render() { const { fetching, claims, navigate, sortBy } = this.props; - return ( {claims && claims.length ? ( diff --git a/src/renderer/redux/actions/publish.js b/src/renderer/redux/actions/publish.js index af0e9709a..4894e6200 100644 --- a/src/renderer/redux/actions/publish.js +++ b/src/renderer/redux/actions/publish.js @@ -16,6 +16,7 @@ import { batchActions, creditsToString, selectPendingById, + selectMyClaimsWithoutChannels, } from 'lbry-redux'; import { selectosNotificationsEnabled } from 'redux/selectors/settings'; import { doNavigate } from 'redux/actions/navigation'; @@ -199,6 +200,7 @@ export const doPublish = (params: PublishParams) => ( ) => { const state = getState(); const myChannels = selectMyChannelClaims(state); + const myClaims = selectMyClaimsWithoutChannels(state); const { name, @@ -223,7 +225,7 @@ export const doPublish = (params: PublishParams) => ( const channelId = namedChannelClaim ? namedChannelClaim.claim_id : ''; const fee = contentIsFree || !price.amount ? undefined : { ...price }; - const metadata = { + const metadata: Metadata = { title, nsfw, license, @@ -262,11 +264,32 @@ export const doPublish = (params: PublishParams) => ( dispatch({ type: ACTIONS.PUBLISH_START }); - const success = () => { - dispatch({ + const success = pendingClaim => { + const actions = []; + + actions.push({ type: ACTIONS.PUBLISH_SUCCESS, }); - dispatch(doNotify({ id: MODALS.PUBLISH }, { uri })); + + actions.push(doNotify({ id: MODALS.PUBLISH }, { uri })); + + // We have to fake a temp claim until the new pending one is returned by claim_list_mine + // We can't rely on claim_list_mine because there might be some delay before the new claims are returned + // Doing this allows us to show the pending claim immediately, it will get overwritten by the real one + const isMatch = claim => claim.claim_id === pendingClaim.claim_id; + const isEdit = myClaims.some(isMatch); + const myNewClaims = isEdit + ? myClaims.map(claim => (isMatch(claim) ? pendingClaim.output : claim)) + : myClaims.concat(pendingClaim.output); + + actions.push({ + type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, + data: { + claims: myNewClaims, + }, + }); + + dispatch(batchActions(...actions)); }; const failure = error => { @@ -281,7 +304,8 @@ export const doPublish = (params: PublishParams) => ( export const doCheckPendingPublishes = () => (dispatch: Dispatch, getState: GetState) => { const state = getState(); const pendingById = selectPendingById(state); - if (!Object.keys(pendingById)) { + + if (!Object.keys(pendingById).length) { return; } @@ -289,8 +313,9 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch, getSta const checkFileList = () => { Lbry.claim_list_mine().then(claims => { + console.log('check'); claims.forEach(claim => { - // If it's confirmed, check that it wasn't pending previously + // If it's confirmed, check if it was pending previously if (claim.confirmations > 0 && pendingById[claim.claim_id]) { delete pendingById[claim.claim_id]; @@ -326,7 +351,6 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch, getSta }); }; - checkFileList(); publishCheckInterval = setInterval(() => { checkFileList(); }, 30000); diff --git a/src/renderer/redux/reducers/subscriptions.js b/src/renderer/redux/reducers/subscriptions.js index 5f007b7c0..ccde02056 100644 --- a/src/renderer/redux/reducers/subscriptions.js +++ b/src/renderer/redux/reducers/subscriptions.js @@ -41,13 +41,18 @@ export default handleActions( action: DoChannelUnsubscribe ): SubscriptionState => { const subscriptionToRemove: Subscription = action.data; - const newSubscriptions = state.subscriptions .slice() .filter(subscription => subscription.channelName !== subscriptionToRemove.channelName); + // Check if we need to remove it from the 'unread' state + const { unread } = state.unread; + if (unread[subscriptionToRemove.uri]) { + delete unread[subscriptionToRemove.uri]; + } return { ...state, + ...unread, subscriptions: newSubscriptions, }; }, diff --git a/src/renderer/scss/all.scss b/src/renderer/scss/all.scss index b2d980ef2..8b421609c 100644 --- a/src/renderer/scss/all.scss +++ b/src/renderer/scss/all.scss @@ -5,5 +5,5 @@ 'component/snack-bar', 'component/content', 'component/pagination', 'component/markdown-preview', 'component/markdown-editor', 'component/scrollbar', 'component/spinner', 'component/nav', 'component/file-list', 'component/file-render', 'component/search', 'component/toggle', - 'component/search', 'component/dat-gui', 'component/item-list', 'component/time', 'component/icon', + 'component/dat-gui', 'component/item-list', 'component/time', 'component/icon', 'component/placeholder', 'component/badge', 'themes/dark'; diff --git a/src/renderer/scss/component/_badge.scss b/src/renderer/scss/component/_badge.scss index e6aaf4eb9..8f3cec21b 100644 --- a/src/renderer/scss/component/_badge.scss +++ b/src/renderer/scss/component/_badge.scss @@ -6,8 +6,8 @@ } .badge--alert { - background-color: #e45454; - color: white; + background-color: $lbry-red-3; + color: $lbry-white; } .badge--free { diff --git a/src/renderer/scss/component/_button.scss b/src/renderer/scss/component/_button.scss index 182ec462a..a12d1a77e 100644 --- a/src/renderer/scss/component/_button.scss +++ b/src/renderer/scss/component/_button.scss @@ -74,8 +74,7 @@ } } - &.btn--disabled:disabled { - // wtf? + &:disabled { cursor: default; &.btn--primary { diff --git a/src/renderer/scss/themes/_dark.scss b/src/renderer/scss/themes/_dark.scss index 41b62c0b0..6248f3e9f 100644 --- a/src/renderer/scss/themes/_dark.scss +++ b/src/renderer/scss/themes/_dark.scss @@ -82,9 +82,18 @@ html[data-theme='dark'] { background-color: rgba($lbry-red-1, 0.1); } - .btn.btn--alt:not(:disabled) { - background-color: rgba($lbry-white, 0.1); - color: $lbry-gray-1; + // + // BUTTON + // + .btn { + &.btn--alt:not(:disabled) { + background-color: rgba($lbry-white, 0.1); + color: $lbry-gray-1; + } + + &.btn--primary:disabled { + background-color: rgba($lbry-teal-5, 0.15); + } } .search__top { @@ -121,10 +130,6 @@ html[data-theme='dark'] { background-color: rgba($lbry-black, 0.7); } - .btn { - color: $lbry-gray-3; - } - .modal { background-color: rgba($lbry-black, 0.9); border: 1px solid rgba($lbry-gray-1, 0.1); diff --git a/src/renderer/types/claim.js b/src/renderer/types/claim.js index dcc8fef1e..a7b86a39e 100644 --- a/src/renderer/types/claim.js +++ b/src/renderer/types/claim.js @@ -14,6 +14,18 @@ export type Metadata = { title: string, thumbnail: ?string, description: ?string, + fee?: + | { + amount: number, // should be a string https://github.com/lbryio/lbry/issues/1576 + currency: string, + address: string, + version: string, + } + | { + // We don't include a version or address in the metadata field when publishing + amount: number, + currency: string, + }, }; // Actual claim type has more values than this diff --git a/yarn.lock b/yarn.lock index 43fed3243..df771ac20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5663,16 +5663,16 @@ lazy-val@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/lazy-val/-/lazy-val-1.0.3.tgz#bb97b200ef00801d94c317e29dc6ed39e31c5edc" -lbry-redux@lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2: +lbry-redux@lbryio/lbry-redux#0e13dd1972e3b40821fee2f9f06e1a0631913aa9: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2375860d6269d0369418879c2531b1d48c4e47f2" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/0e13dd1972e3b40821fee2f9f06e1a0631913aa9" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0" -lbry-redux@lbryio/lbry-redux#f193d38c61ea061679ebc7b4ca139a0e9c95ef8a: +lbry-redux@lbryio/lbry-redux#2375860d6269d0369418879c2531b1d48c4e47f2: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/f193d38c61ea061679ebc7b4ca139a0e9c95ef8a" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2375860d6269d0369418879c2531b1d48c4e47f2" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0"