mirror of
https://github.com/wekan/wekan.git
synced 2026-03-14 01:16:13 +01:00
Move every Cards.findOne() to the ReactiveCache
This commit is contained in:
parent
a182482cfb
commit
3b65113d05
24 changed files with 96 additions and 87 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
import Cards from '../../models/cards';
|
||||
import SessionData from '../../models/usersessiondata';
|
||||
|
|
@ -74,7 +75,7 @@ export class CardSearchPagedComponent extends BlazeComponent {
|
|||
console.log('session data:', this.sessionData);
|
||||
const cards = [];
|
||||
this.sessionData.cards.forEach(cardId => {
|
||||
cards.push(Cards.findOne({ _id: cardId }));
|
||||
cards.push(ReactiveCache.getCard(cardId));
|
||||
});
|
||||
this.queryErrors = this.sessionData.errors;
|
||||
if (this.queryErrors.length) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Mousetrap.bind(numbArray, (evt, key) => {
|
|||
const cardIds = MultiSelection.getSelectedCardIds();
|
||||
for (const cardId of cardIds)
|
||||
{
|
||||
card = Cards.findOne(cardId);
|
||||
card = ReactiveCache.getCard(cardId);
|
||||
if(num <= board.labels.length)
|
||||
{
|
||||
card.removeLabel(labels[num-1]["_id"]);
|
||||
|
|
@ -109,7 +109,7 @@ Mousetrap.bind(numArray, (evt, key) => {
|
|||
const cardIds = MultiSelection.getSelectedCardIds();
|
||||
for (const cardId of cardIds)
|
||||
{
|
||||
card = Cards.findOne(cardId);
|
||||
card = ReactiveCache.getCard(cardId);
|
||||
if(num <= board.labels.length)
|
||||
{
|
||||
card.addLabel(labels[num-1]["_id"]);
|
||||
|
|
@ -123,7 +123,7 @@ Mousetrap.bind(numArray, (evt, key) => {
|
|||
return;
|
||||
}
|
||||
if (Meteor.user().isBoardMember()) {
|
||||
const card = Cards.findOne(cardId);
|
||||
const card = ReactiveCache.getCard(cardId);
|
||||
if(num <= board.labels.length)
|
||||
{
|
||||
card.toggleLabel(labels[num-1]["_id"]);
|
||||
|
|
@ -143,7 +143,7 @@ Mousetrap.bind('space', evt => {
|
|||
}
|
||||
|
||||
if (Meteor.user().isBoardMember()) {
|
||||
const card = Cards.findOne(cardId);
|
||||
const card = ReactiveCache.getCard(cardId);
|
||||
card.toggleMember(currentUserId);
|
||||
// We should prevent scrolling in card when spacebar is clicked
|
||||
// This should do it according to Mousetrap docs, but it doesn't
|
||||
|
|
@ -167,7 +167,7 @@ Mousetrap.bind('c', evt => {
|
|||
!Meteor.user().isCommentOnly() &&
|
||||
!Meteor.user().isWorker()
|
||||
) {
|
||||
const card = Cards.findOne(cardId);
|
||||
const card = ReactiveCache.getCard(cardId);
|
||||
card.archive();
|
||||
// We should prevent scrolling in card when spacebar is clicked
|
||||
// This should do it according to Mousetrap docs, but it doesn't
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
function getCardsBetween(idA, idB) {
|
||||
function pluckId(doc) {
|
||||
return doc._id;
|
||||
|
|
@ -13,7 +15,7 @@ function getCardsBetween(idA, idB) {
|
|||
}).map(pluckId);
|
||||
}
|
||||
|
||||
const cards = _.sortBy([Cards.findOne(idA), Cards.findOne(idB)], c => {
|
||||
const cards = _.sortBy([ReactiveCache.getCard(idA), ReactiveCache.getCard(idB)], c => {
|
||||
return c.sort;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ Utils = {
|
|||
},
|
||||
|
||||
goCardId(_id) {
|
||||
const card = Cards.findOne(_id);
|
||||
const card = ReactiveCache.getCard(_id);
|
||||
const board = ReactiveCache.getBoard(card.boardId);
|
||||
return (
|
||||
board &&
|
||||
|
|
@ -226,7 +226,7 @@ Utils = {
|
|||
getCommonAttachmentMetaFrom(card) {
|
||||
const meta = {};
|
||||
if (card.isLinkedCard()) {
|
||||
meta.boardId = Cards.findOne(card.linkedId).boardId;
|
||||
meta.boardId = ReactiveCache.getCard(card.linkedId).boardId;
|
||||
meta.cardId = card.linkedId;
|
||||
} else {
|
||||
meta.boardId = card.boardId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue