Move every Cards.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory client/)

This commit is contained in:
Martin Filser 2023-02-14 18:52:36 +01:00
parent 66c2140911
commit 7673c77c57
11 changed files with 38 additions and 34 deletions

View file

@ -279,10 +279,10 @@ Template.memberPopup.events({
// This works from removing member from board, card members and assignees.
const boardId = Session.get('currentBoard');
const memberId = this.userId;
Cards.find({ boardId, members: memberId }).forEach(card => {
ReactiveCache.getCards({ boardId, members: memberId }).forEach(card => {
card.unassignMember(memberId);
});
Cards.find({ boardId, assignees: memberId }).forEach(card => {
ReactiveCache.getCards({ boardId, assignees: memberId }).forEach(card => {
card.unassignAssignee(memberId);
});
ReactiveCache.getBoard(boardId).removeMember(memberId);

View file

@ -34,7 +34,7 @@ BlazeComponent.extendComponent({
},
archivedCards() {
return Cards.find(
const ret = ReactiveCache.getCards(
{
archived: true,
boardId: Session.get('currentBoard'),
@ -43,6 +43,7 @@ BlazeComponent.extendComponent({
sort: { archivedAt: -1, modifiedAt: -1 },
},
);
return ret;
},
archivedLists() {

View file

@ -95,7 +95,7 @@ BlazeComponent.extendComponent({
},
'click .js-filter-to-selection'(evt) {
evt.preventDefault();
const selectedCards = Cards.find(Filter.mongoSelector()).map(c => {
const selectedCards = ReactiveCache.getCards(Filter.mongoSelector()).map(c => {
return c._id;
});
MultiSelection.add(selectedCards);
@ -106,14 +106,14 @@ BlazeComponent.extendComponent({
}).register('filterSidebar');
function mutateSelectedCards(mutationName, ...args) {
Cards.find(MultiSelection.getMongoSelector(), {sort: ['sort']}).forEach(card => {
ReactiveCache.getCards(MultiSelection.getMongoSelector(), {sort: ['sort']}).forEach(card => {
card[mutationName](...args);
});
}
BlazeComponent.extendComponent({
mapSelection(kind, _id) {
return Cards.find(MultiSelection.getMongoSelector(), {sort: ['sort']}).map(card => {
return ReactiveCache.getCards(MultiSelection.getMongoSelector(), {sort: ['sort']}).map(card => {
const methodName = kind === 'label' ? 'hasLabel' : 'isAssigned';
return card[methodName](_id);
});