wekan/server/publications/activities.js
Martin Filser 8a446de3e9 added comment section on card details to avoid loading the card comment activities from the server
- and added to show only the activities a card

- to display the card comments a connection to the server was needed to get the activities of the card comments, now, it's not necessary
- also performance relevant. until now there were a lot of activities loaded, now only of the current card
2024-11-15 19:55:07 +01:00

41 lines
1 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
// We use activities fields at two different places:
// 1. The board sidebar
// 2. The card activity tab
// We use this publication to paginate for these two publications.
Meteor.publish('activities', (kind, id, limit, showActivities) => {
check(
kind,
Match.Where(x => {
return ['board', 'card'].indexOf(x) !== -1;
}),
);
check(id, String);
check(limit, Number);
check(showActivities, Boolean);
// Get linkedBoard
let linkedElmtId = [id];
if (kind == 'board') {
ReactiveCache.getCards({
"type": "cardType-linkedBoard",
"boardId": id}
).forEach(card => {
linkedElmtId.push(card.linkedId);
});
}
const selector = showActivities
? { [`${kind}Id`]: { $in: linkedElmtId } }
: { $and: [{ activityType: 'addComment' }, { [`${kind}Id`]: { $in: linkedElmtId } }] };
const ret = ReactiveCache.getActivities(selector,
{
limit,
sort: { createdAt: -1 },
},
true,
);
return ret;
});