1
0
Fork 0
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:
HannesOberreiter 2025-05-23 10:23:59 +02:00
parent 86cfd155f2
commit aea482ba03
2 changed files with 32 additions and 0 deletions

View file

@ -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}

View file

@ -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,
};