diff --git a/CHANGELOG.md b/CHANGELOG.md index 7970ae03a..544357b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix comment section redirection to create channel _community pr!_ ([#6557](https://github.com/lbryio/lbry-desktop/pull/6557)) - Clicking on the title of a floating player will take you back to the list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921)) - Fix floating player stopping on markdown or image files ([#7073](https://github.com/lbryio/lbry-desktop/pull/7073)) +- Fix list thumbnail upload ([#7074](https://github.com/lbryio/lbry-desktop/pull/7074)) ## [0.51.1] - [2021-06-26] diff --git a/package.json b/package.json index 817820f4e..83ff38a0a 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,7 @@ "imagesloaded": "^4.1.4", "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#372e559caee6af2b2d927e5d42419a71c3d15b57", + "lbry-redux": "lbryio/lbry-redux#129b0ea3faa5da69ef1b85ea9ab7777b06aa3264", "lbryinc": "lbryio/lbryinc#0b4e41ef90d6347819dd3453f2f9398a5c1b4f36", "lint-staged": "^7.0.2", "localforage": "^1.7.1", diff --git a/ui/component/collectionEdit/index.js b/ui/component/collectionEdit/index.js index aa673b1e6..d95aa4a4e 100644 --- a/ui/component/collectionEdit/index.js +++ b/ui/component/collectionEdit/index.js @@ -17,7 +17,6 @@ import { makeSelectClaimIdsForCollectionId, ACTIONS as LBRY_REDUX_ACTIONS, } from 'lbry-redux'; -import { doOpenModal } from 'redux/actions/app'; import CollectionForm from './view'; import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app'; @@ -44,7 +43,6 @@ const select = (state, props) => ({ }); const perform = (dispatch) => ({ - openModal: (modal, props) => dispatch(doOpenModal(modal, props)), publishCollectionUpdate: (params) => dispatch(doCollectionPublishUpdate(params)), publishCollection: (params, collectionId) => dispatch(doCollectionPublish(params, collectionId)), clearCollectionErrors: () => dispatch({ type: LBRY_REDUX_ACTIONS.CLEAR_COLLECTION_ERRORS }), diff --git a/ui/component/collectionEdit/view.jsx b/ui/component/collectionEdit/view.jsx index fbb3794aa..371d7df7f 100644 --- a/ui/component/collectionEdit/view.jsx +++ b/ui/component/collectionEdit/view.jsx @@ -10,9 +10,9 @@ import ChannelSelector from 'component/channelSelector'; import ClaimList from 'component/claimList'; import Card from 'component/common/card'; import LbcSymbol from 'component/common/lbc-symbol'; -import ThumbnailPicker from 'component/thumbnailPicker'; +import SelectThumbnail from 'component/selectThumbnail'; import { useHistory } from 'react-router-dom'; -import { isNameValid, regexInvalidURI } from 'lbry-redux'; +import { isNameValid, regexInvalidURI, THUMBNAIL_STATUSES } from 'lbry-redux'; import { Tabs, TabList, Tab, TabPanels, TabPanel } from 'component/common/tabs'; import { FormField } from 'component/common/form'; import { handleBidChange } from 'util/publish'; @@ -21,6 +21,7 @@ import { INVALID_NAME_ERROR } from 'constants/claim'; import SUPPORTED_LANGUAGES from 'constants/supported_languages'; import * as PAGES from 'constants/pages'; import analytics from 'analytics'; + const LANG_NONE = 'none'; const MAX_TAG_SELECT = 5; @@ -39,23 +40,18 @@ type Props = { tags: Array, locations: Array, languages: Array, - collectionId: string, collection: Collection, collectionClaimIds: Array, collectionUrls: Array, - publishCollectionUpdate: (CollectionUpdateParams) => Promise, updatingCollection: boolean, updateError: string, - publishCollection: (CollectionPublishParams, string) => Promise, createError: string, creatingCollection: boolean, + publishCollectionUpdate: (CollectionUpdateParams) => Promise, + publishCollection: (CollectionPublishParams, string) => Promise, clearCollectionErrors: () => void, onDone: (string) => void, - openModal: ( - id: string, - { onUpdate: (string) => void, assetName: string, helpText: string, currentValue: string, title: string } - ) => void, }; function CollectionForm(props: Props) { @@ -72,11 +68,8 @@ function CollectionForm(props: Props) { locations, languages = [], // rest - onDone, - publishCollectionUpdate, updateError, updatingCollection, - publishCollection, creatingCollection, createError, disabled, @@ -86,7 +79,10 @@ function CollectionForm(props: Props) { collection, collectionUrls, collectionClaimIds, + publishCollectionUpdate, + publishCollection, clearCollectionErrors, + onDone, } = props; const activeChannelName = activeChannelClaim && activeChannelClaim.name; let prefix = IS_WEB ? `${DOMAIN}/` : 'lbry://'; @@ -107,6 +103,11 @@ function CollectionForm(props: Props) { const secondaryLanguage = Array.isArray(languageParam) && languageParam.length >= 2 && languageParam[1]; const collectionClaimIdsString = JSON.stringify(collectionClaimIds); + const itemError = !params.claims.length ? __('Cannot publish empty list') : ''; + const thumbnailError = + (params.thumbnail_error && params.thumbnail_status !== THUMBNAIL_STATUSES.COMPLETE && __('Invalid thumbnail')) || + (params.thumbnail_status === THUMBNAIL_STATUSES.IN_PROGRESS && __('Please wait for thumbnail to finish uploading')); + const submitError = nameError || bidError || itemError || updateError || createError || thumbnailError; function parseName(newName) { let INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu'); @@ -142,6 +143,8 @@ function CollectionForm(props: Props) { function getCollectionParams() { const collectionParams: { thumbnail_url?: string, + thumbnail_error?: boolean, + thumbnail_status?: string, name?: string, description?: string, title?: string, @@ -154,7 +157,9 @@ function CollectionForm(props: Props) { claims: ?Array, } = { thumbnail_url: thumbnailUrl, + name: parseName(collectionName), description, + title: claim ? title : collectionName, bid: String(amount || 0.001), languages: languages ? dedupeLanguages(languages) : [], locations: locations || [], @@ -163,32 +168,14 @@ function CollectionForm(props: Props) { return { name: tag }; }) : [], + claim_id: String(claim && claim.claim_id), + channel_id: String(activeChannelId && parseName(collectionName)), claims: collectionClaimIds, }; - collectionParams['name'] = parseName(collectionName); - - if (activeChannelId) { - collectionParams['channel_id'] = activeChannelId; - } - - if (!claim) { - collectionParams['title'] = collectionName; - } - - if (claim) { - collectionParams['claim_id'] = claim.claim_id; - collectionParams['title'] = title; - } return collectionParams; } - React.useEffect(() => { - const collectionClaimIds = JSON.parse(collectionClaimIdsString); - setParams({ ...params, claims: collectionClaimIds }); - clearCollectionErrors(); - }, [collectionClaimIdsString, setParams]); - function handleLanguageChange(index, code) { let langs = [...languageParam]; if (index === 0) { @@ -211,10 +198,6 @@ function CollectionForm(props: Props) { setParams({ ...params, languages: langs }); } - function handleThumbnailChange(thumbnailUrl: string) { - setParams({ ...params, thumbnail_url: thumbnailUrl }); - } - function handleSubmit() { if (uri) { publishCollectionUpdate(params).then((pendingClaim) => { @@ -235,6 +218,12 @@ function CollectionForm(props: Props) { } } + React.useEffect(() => { + const collectionClaimIds = JSON.parse(collectionClaimIdsString); + setParams({ ...params, claims: collectionClaimIds }); + clearCollectionErrors(); + }, [collectionClaimIdsString, setParams]); + React.useEffect(() => { let nameError; if (!name && name !== undefined) { @@ -247,17 +236,14 @@ function CollectionForm(props: Props) { }, [name]); React.useEffect(() => { - if (incognito) { + if (incognito && params.channel_id) { const newParams = Object.assign({}, params); delete newParams.channel_id; setParams(newParams); - } else if (activeChannelId) { + } else if (activeChannelId && params.channel_id !== activeChannelId) { setParams({ ...params, channel_id: activeChannelId }); } - }, [activeChannelId, incognito, setParams]); - - const itemError = !params.claims.length ? __('Cannot publish empty list') : ''; - const submitError = nameError || bidError || itemError || updateError || createError; + }, [activeChannelId, incognito, params, setParams]); return ( <> @@ -277,11 +263,6 @@ function CollectionForm(props: Props) { - - - - - @@ -311,11 +292,15 @@ function CollectionForm(props: Props) { value={params.title} onChange={(e) => setParams({ ...params, title: e.target.value })} /> - + + +