add 'new' badge on every page in the app
This commit is contained in:
parent
82805a46a4
commit
e0d6537c96
7 changed files with 42 additions and 8 deletions
|
@ -2,7 +2,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
text: string,
|
text: ?string,
|
||||||
lines: number,
|
lines: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
makeSelectContentPositionForUri,
|
makeSelectContentPositionForUri,
|
||||||
} from 'redux/selectors/content';
|
} from 'redux/selectors/content';
|
||||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
import { makeSelectIsSubscribed, makeSelectIsNew } from 'redux/selectors/subscriptions';
|
||||||
import { doClearContentHistoryUri } from 'redux/actions/content';
|
import { doClearContentHistoryUri } from 'redux/actions/content';
|
||||||
import FileCard from './view';
|
import FileCard from './view';
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ const select = (state, props) => ({
|
||||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||||
position: makeSelectContentPositionForUri(props.uri)(state),
|
position: makeSelectContentPositionForUri(props.uri)(state),
|
||||||
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
|
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
|
||||||
|
isNew: makeSelectIsNew(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import { doNavigate } from 'redux/actions/navigation';
|
import { doNavigate } from 'redux/actions/navigation';
|
||||||
import { doClearPublish, doUpdatePublishForm } from 'redux/actions/publish';
|
import { doClearPublish, doUpdatePublishForm } from 'redux/actions/publish';
|
||||||
import { selectRewardContentClaimIds } from 'redux/selectors/content';
|
import { selectRewardContentClaimIds } from 'redux/selectors/content';
|
||||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
import { makeSelectIsSubscribed, makeSelectIsNew } from 'redux/selectors/subscriptions';
|
||||||
import FileTile from './view';
|
import FileTile from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
|
@ -23,6 +23,7 @@ const select = (state, props) => ({
|
||||||
obscureNsfw: !selectShowNsfw(state),
|
obscureNsfw: !selectShowNsfw(state),
|
||||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
|
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
|
||||||
|
isNew: makeSelectIsNew(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -30,6 +30,7 @@ type Props = {
|
||||||
displayDescription?: boolean,
|
displayDescription?: boolean,
|
||||||
size: string,
|
size: string,
|
||||||
isSubscribed: boolean,
|
isSubscribed: boolean,
|
||||||
|
isNew: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileTile extends React.PureComponent<Props> {
|
class FileTile extends React.PureComponent<Props> {
|
||||||
|
@ -49,15 +50,24 @@ class FileTile extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderFileProperties() {
|
renderFileProperties() {
|
||||||
const { isSubscribed, isDownloaded, claim, uri, rewardedContentClaimIds, size } = this.props;
|
const {
|
||||||
|
isSubscribed,
|
||||||
|
isDownloaded,
|
||||||
|
claim,
|
||||||
|
uri,
|
||||||
|
rewardedContentClaimIds,
|
||||||
|
size,
|
||||||
|
isNew,
|
||||||
|
} = this.props;
|
||||||
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classnames('card__file-properties', { card__subtitle: size === 'large' })}>
|
<div className={classnames('card__file-properties', { card__subtitle: size === 'large' })}>
|
||||||
<FilePrice hideFree uri={uri} />
|
<FilePrice hideFree uri={uri} />
|
||||||
{isSubscribed && <Icon icon={ICONS.HEART} />}
|
{isNew && <span className="badge badge--alert icon">{__('NEW')}</span>}
|
||||||
{isRewardContent && <Icon iconColor="red" icon={ICONS.FEATURED} />}
|
{isSubscribed && <Icon icon={icons.HEART} />}
|
||||||
{isDownloaded && <Icon icon={ICONS.LOCAL} />}
|
{isRewardContent && <Icon iconColor="red" icon={icons.FEATURED} />}
|
||||||
|
{isDownloaded && <Icon icon={icons.LOCAL} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ export default (props: Props) => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="card__list card__content">
|
<div className="card__list card__content">
|
||||||
{uris.map(uri => <FileCard isNew key={uri} uri={uri} />)}
|
{uris.map(uri => <FileCard key={uri} uri={uri} />)}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|
|
@ -253,3 +253,24 @@ export const makeSelectIsSubscribed = uri =>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const makeSelectIsNew = uri =>
|
||||||
|
createSelector(
|
||||||
|
makeSelectIsSubscribed(uri),
|
||||||
|
makeSelectChannelForClaimUri(uri),
|
||||||
|
selectUnreadByChannel,
|
||||||
|
(isSubscribed, channel, unreadByChannel) => {
|
||||||
|
if (!isSubscribed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// console.log("uri", uri)
|
||||||
|
// console.log("channel", channel)
|
||||||
|
const unreadForChannel = unreadByChannel[`lbry://${channel}`];
|
||||||
|
if (unreadForChannel) {
|
||||||
|
return unreadForChannel.uris.includes(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
// If they are subscribed, check to see if this uri is in the list of unreads
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
|
@ -324,6 +324,7 @@
|
||||||
|
|
||||||
.card-row__scrollhouse {
|
.card-row__scrollhouse {
|
||||||
padding-top: $spacing-vertical * 2/3;
|
padding-top: $spacing-vertical * 2/3;
|
||||||
|
padding-bottom: $spacing-vertical * 1/6;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
|
|
Loading…
Add table
Reference in a new issue