Show on content page if a file is part of a playlist already

This commit is contained in:
saltrafael 2021-07-23 11:24:32 -03:00 committed by zeppi
parent 413b19a7e9
commit e76eddbf56
4 changed files with 25 additions and 8 deletions

View file

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add watch later to hover action for last used playlist on popup _community pr!_ ([#6274](https://github.com/lbryio/lbry-desktop/pull/6274)) - Add watch later to hover action for last used playlist on popup _community pr!_ ([#6274](https://github.com/lbryio/lbry-desktop/pull/6274))
- Open in desktop (web feature) _community pr!_ ([#6667](https://github.com/lbryio/lbry-desktop/pull/6667)) - Open in desktop (web feature) _community pr!_ ([#6667](https://github.com/lbryio/lbry-desktop/pull/6667))
- Add confirmation on comment removal _community pr!_ ([#6563](https://github.com/lbryio/lbry-desktop/pull/6563)) - Add confirmation on comment removal _community pr!_ ([#6563](https://github.com/lbryio/lbry-desktop/pull/6563))
- Show on content page if a file is part of a playlist already _community pr!_([#6393](https://github.com/lbryio/lbry-desktop/pull/6393))
### Changed ### Changed
- Use Canonical Url for copy link ([#6500](https://github.com/lbryio/lbry-desktop/pull/6500)) - Use Canonical Url for copy link ([#6500](https://github.com/lbryio/lbry-desktop/pull/6500))

View file

@ -1,11 +1,17 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';
import CollectionAddButton from './view'; import CollectionAddButton from './view';
import { makeSelectClaimForUri } from 'lbry-redux'; import { makeSelectClaimForUri, makeSelectClaimUrlInCollection } from 'lbry-redux';
const select = (state, props) => ({ const select = (state, props) => {
claim: makeSelectClaimForUri(props.uri)(state), const claim = makeSelectClaimForUri(props.uri)(state);
}); const permanentUrl = claim && claim.permanent_url;
return {
claim,
isSaved: makeSelectClaimUrlInCollection(permanentUrl)(state),
};
};
export default connect(select, { export default connect(select, {
doOpenModal, doOpenModal,

View file

@ -11,10 +11,11 @@ type Props = {
fileAction?: boolean, fileAction?: boolean,
type?: boolean, type?: boolean,
claim: Claim, claim: Claim,
isSaved: boolean,
}; };
export default function CollectionAddButton(props: Props) { export default function CollectionAddButton(props: Props) {
const { doOpenModal, uri, fileAction, type = 'playlist', claim } = props; const { doOpenModal, uri, fileAction, type = 'playlist', claim, isSaved } = props;
// $FlowFixMe // $FlowFixMe
const streamType = (claim && claim.value && claim.value.stream_type) || ''; const streamType = (claim && claim.value && claim.value.stream_type) || '';
@ -24,10 +25,14 @@ export default function CollectionAddButton(props: Props) {
return ( return (
<Button <Button
button={fileAction ? undefined : 'alt'} button={fileAction ? undefined : 'alt'}
className={classnames({ 'button--file-action': fileAction })} className={classnames({
icon={fileAction ? ICONS.ADD : ICONS.LIBRARY} 'button--file-action': fileAction,
'button--file-action-active': fileAction && isSaved,
})}
icon={fileAction ? (!isSaved ? ICONS.ADD : ICONS.STACK) : ICONS.LIBRARY}
iconSize={fileAction ? 22 : undefined} iconSize={fileAction ? 22 : undefined}
label={uri ? __('Save') : __('New List')} iconColor={isSaved && 'green'}
label={uri ? (!isSaved ? __('Save') : __('Saved')) : __('New List')}
requiresAuth={IS_WEB} requiresAuth={IS_WEB}
title={__('Add this claim to a list')} title={__('Add this claim to a list')}
onClick={(e) => { onClick={(e) => {

View file

@ -240,6 +240,11 @@
} }
} }
.button--file-action-active {
@extend .button--file-action;
color: var(--color-link);
}
.button--fire { .button--fire {
color: var(--color-fire); color: var(--color-fire);
position: relative; position: relative;