Move every Boards.findOne(boardId) to the ReactiveCache (Part 2)

This commit is contained in:
Martin Filser 2023-01-14 13:29:57 +01:00
parent 9022e9949f
commit a182482cfb
37 changed files with 166 additions and 127 deletions

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import Fiber from 'fibers';
Meteor.startup(() => {
@ -55,7 +56,7 @@ Meteor.startup(() => {
Authentication.checkBoardAccess = function(userId, boardId) {
Authentication.checkLoggedIn(userId);
const board = Boards.findOne({ _id: boardId });
const board = ReactiveCache.getBoard(boardId);
const normalAccess =
board.permission === 'public' ||
board.members.some(e => e.userId === userId && e.isActive);

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
if (Meteor.isServer) {
@ -79,7 +80,7 @@ if (Meteor.isServer) {
cardId: paramCardId,
boardId: paramBoardId,
});
const board = Boards.findOne(paramBoardId);
const board = ReactiveCache.getBoard(paramBoardId);
const card = Cards.findOne(paramCardId);
if (board && card) {
if (comment) {

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
Meteor.methods({
watch(watchableType, id, level) {
check(watchableType, String);
@ -9,7 +11,7 @@ Meteor.methods({
let watchableObj = null;
let board = null;
if (watchableType === 'board') {
watchableObj = Boards.findOne(id);
watchableObj = ReactiveCache.getBoard(id);
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
board = watchableObj;
} else if (watchableType === 'list') {

View file

@ -2,6 +2,7 @@
// non-archived boards:
// 1. that the user is a member of
// 2. the user has starred
import { ReactiveCache } from '/imports/reactiveCache';
import Users from "../../models/users";
import Org from "../../models/org";
import Team from "../../models/team";
@ -326,7 +327,7 @@ Meteor.methods({
check(boardId, String);
check(properties, Object);
const board = Boards.findOne(boardId);
const board = ReactiveCache.getBoard(boardId);
if (board) {
for (const key in properties) {
board[key] = properties[key];

View file

@ -1,10 +1,12 @@
import { ReactiveCache } from '/imports/reactiveCache';
Meteor.methods({
copySwimlane(swimlaneId, toBoardId) {
check(swimlaneId, String);
check(toBoardId, String);
const swimlane = Swimlanes.findOne(swimlaneId);
const toBoard = Boards.findOne(toBoardId);
const toBoard = ReactiveCache.getBoard(toBoardId);
if (swimlane && toBoard) {
swimlane.copy(toBoardId);
@ -19,7 +21,7 @@ Meteor.methods({
check(toBoardId, String);
const swimlane = Swimlanes.findOne(swimlaneId);
const toBoard = Boards.findOne(toBoardId);
const toBoard = ReactiveCache.getBoard(toBoardId);
if (swimlane && toBoard) {
swimlane.move(toBoardId);