Move every Boards.findOne(idOrFirstObjectSelector, options) to the ReactiveCache

This commit is contained in:
Martin Filser 2023-02-04 16:57:56 +01:00
parent 06e374f0ff
commit 2c92524cf4
6 changed files with 15 additions and 13 deletions

View file

@ -1689,7 +1689,7 @@ if (Meteor.isServer) {
Meteor.methods({
getBackgroundImageURL(boardId) {
check(boardId, String);
return Boards.findOne({ boardId: boardId }, {}, { backgroundImageUrl: 1 });
return ReactiveCache.getBoard(boardId, {}, { backgroundImageUrl: 1 });
},
quitBoard(boardId) {
check(boardId, String);
@ -1781,7 +1781,7 @@ if (Meteor.isServer) {
// Insert new board at last position in sort order.
Boards.before.insert((userId, doc) => {
const lastBoard = Boards.findOne(
const lastBoard = ReactiveCache.getBoard(
{ sort: { $exists: true } },
{ sort: { sort: -1 } },
);
@ -2061,7 +2061,7 @@ if (Meteor.isServer) {
JsonRoutes.sendResult(res, {
code: 200,
data: Boards.findOne({ _id: paramBoardId }),
data: ReactiveCache.getBoard(paramBoardId),
});
} catch (error) {
JsonRoutes.sendResult(res, {
@ -2178,7 +2178,7 @@ if (Meteor.isServer) {
Authentication.checkBoardAccess(req.userId, id);
try {
if (req.body.hasOwnProperty('label')) {
const board = Boards.findOne({ _id: id });
const board = ReactiveCache.getBoard(id);
const color = req.body.label.color;
const name = req.body.label.name;
const labelId = Random.id(6);
@ -2225,7 +2225,7 @@ if (Meteor.isServer) {
const boardId = req.params.boardId;
const memberId = req.params.memberId;
const { isAdmin, isNoComments, isCommentOnly, isWorker } = req.body;
const board = Boards.findOne({ _id: boardId });
const board = ReactiveCache.getBoard(boardId);
function isTrue(data) {
try {
return data.toLowerCase() === 'true';

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
// exporter maybe is broken since Gridfs introduced, add fs and path
import { createWorkbook } from './createWorkbook';
@ -33,7 +34,7 @@ class ExporterCardPDF {
};
_.extend(
result,
Boards.findOne(this._boardId, {
ReactiveCache.getBoard(this._boardId, {
fields: {
stars: 0,
},
@ -621,7 +622,7 @@ class ExporterCardPDF {
}
canExport(user) {
const board = Boards.findOne(this._boardId);
const board = ReactiveCache.getBoard(this._boardId);
return board && board.isVisibleBy(user);
}
}

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import moment from 'moment/min/moment-with-locales';
import { TAPi18n } from '/imports/i18n';
import { createWorkbook } from './createWorkbook';
@ -35,7 +36,7 @@ class ExporterExcel {
};
_.extend(
result,
Boards.findOne(this._boardId, {
ReactiveCache.getBoard(this._boardId, {
fields: {
stars: 0,
},
@ -886,7 +887,7 @@ class ExporterExcel {
}
canExport(user) {
const board = Boards.findOne(this._boardId);
const board = ReactiveCache.getBoard(this._boardId);
return board && board.isVisibleBy(user);
}
}

View file

@ -899,7 +899,7 @@ Users.helpers({
},
getTemplatesBoardSlug() {
//return (Boards.findOne((this.profile || {}).templatesBoardId) || {}).slug;
//return (ReactiveCache.getBoard((this.profile || {}).templatesBoardId) || {}).slug;
return 'templates';
},