Move every Meteor.user() to the ReactiveCache

This commit is contained in:
Martin Filser 2023-01-16 23:00:10 +01:00
parent 6e1ef3d94a
commit 5e3a9dc059
42 changed files with 211 additions and 252 deletions

View file

@ -107,7 +107,7 @@ if (Meteor.isServer) {
};
Meteor.methods({
outgoingWebhooks(integration, description, params) {
if (Meteor.user()) {
if (ReactiveCache.getCurrentUser()) {
check(integration, Object);
check(description, String);
check(params, Object);

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import moment from 'moment/min/moment-with-locales';
import escapeForRegex from 'escape-string-regexp';
import Users from '../../models/users';
@ -78,7 +79,7 @@ Meteor.publish('myCards', function(sessionId) {
check(sessionId, String);
const queryParams = new QueryParams();
queryParams.addPredicate(OPERATOR_USER, Meteor.user().username);
queryParams.addPredicate(OPERATOR_USER, ReactiveCache.getCurrentUser().username);
queryParams.setPredicate(OPERATOR_LIMIT, 200);
const query = buildQuery(queryParams);
@ -106,7 +107,7 @@ Meteor.publish('myCards', function(sessionId) {
// };
//
// if (!allUsers) {
// queryParams.users = [Meteor.user().username];
// queryParams.users = [ReactiveCache.getCurrentUser().username];
// }
//
// return buildQuery(sessionId, queryParams);

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
// We use these when displaying notifications in the notificationsDrawer
// gets all activities associated with the current user
@ -94,7 +96,7 @@ Meteor.publish('notificationUsers', function() {
});
function activities() {
const activityIds = Meteor.user()?.profile?.notifications?.map(v => v.activity) || [];
const activityIds = ReactiveCache.getCurrentUser()?.profile?.notifications?.map(v => v.activity) || [];
let ret = [];
if (activityIds.length > 0) {
ret = Activities.find({

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { MongoInternals } from 'meteor/mongo';
// Sandstorm context is detected using the METEOR_SETTINGS environment variable
@ -8,7 +9,7 @@ const isSandstorm =
if (Meteor.isServer) {
Meteor.methods({
getStatistics() {
if (Meteor.user() && Meteor.user().isAdmin) {
if (ReactiveCache.getCurrentUser()?.isAdmin) {
const os = require('os');
const pjson = require('/package.json');
const statistics = {};