mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
feat: ✨ show count of comments on card information
This commit is contained in:
parent
86cfd155f2
commit
aea482ba03
2 changed files with 32 additions and 0 deletions
|
@ -49,6 +49,11 @@ const ProjectContent = React.memo(({ cardId }) => {
|
|||
[],
|
||||
);
|
||||
|
||||
const selectCommentsTotalByCardId = useMemo(
|
||||
() => selectors.makeSelectCommentsTotalByCardId(),
|
||||
[],
|
||||
);
|
||||
|
||||
const selectAttachmentById = useMemo(() => selectors.makeSelectAttachmentById(), []);
|
||||
|
||||
const card = useSelector((state) => selectCardById(state, cardId));
|
||||
|
@ -70,6 +75,8 @@ const ProjectContent = React.memo(({ cardId }) => {
|
|||
selectNotificationsTotalByCardId(state, cardId),
|
||||
);
|
||||
|
||||
const commentsTotal = useSelector((state) => selectCommentsTotalByCardId(state, cardId));
|
||||
|
||||
const coverUrl = useSelector((state) => {
|
||||
const attachment = selectAttachmentById(state, card.coverAttachmentId);
|
||||
return attachment && attachment.data.thumbnailUrls.outside360;
|
||||
|
@ -116,6 +123,7 @@ const ProjectContent = React.memo(({ cardId }) => {
|
|||
card.stopwatch ||
|
||||
attachmentsTotal > 0 ||
|
||||
notificationsTotal > 0 ||
|
||||
commentsTotal > 0 ||
|
||||
listName;
|
||||
|
||||
const isCompact =
|
||||
|
@ -226,6 +234,14 @@ const ProjectContent = React.memo(({ cardId }) => {
|
|||
</span>
|
||||
</span>
|
||||
)}
|
||||
{commentsTotal > 0 && (
|
||||
<span className={classNames(styles.attachment, styles.attachmentLeft)}>
|
||||
<span className={styles.attachmentContent}>
|
||||
<Icon name="comment outline" />
|
||||
{commentsTotal}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
{!isCompact && usersNode}
|
||||
|
|
|
@ -28,7 +28,23 @@ export const makeSelectCommentById = () =>
|
|||
|
||||
export const selectCommentById = makeSelectCommentById();
|
||||
|
||||
export const makeSelectCommentsTotalByCardId = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, cardId) => cardId,
|
||||
({ Card }, cardId) => {
|
||||
const cardModel = Card.withId(cardId);
|
||||
|
||||
if (!cardModel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cardModel.comments.count();
|
||||
},
|
||||
);
|
||||
|
||||
export default {
|
||||
makeSelectCommentById,
|
||||
selectCommentById,
|
||||
makeSelectCommentsTotalByCardId,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue