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

@ -24,14 +24,6 @@ BlazeComponent.extendComponent({
onRendered() {
const boardComponent = this.parentComponent().parentComponent();
function userIsMember() {
return (
Meteor.user() &&
Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly()
);
}
const itemsSelector = '.js-minicard:not(.placeholder, .js-card-composer)';
const $cards = this.$('.js-minicards');
@ -170,9 +162,9 @@ BlazeComponent.extendComponent({
'option',
'disabled',
// Disable drag-dropping when user is not member
!userIsMember(),
!Utils.canModifyBoard(),
// Not disable drag-dropping while in multi-selection mode
// MultiSelection.isActive() || !userIsMember(),
// MultiSelection.isActive() || !Utils.canModifyBoard(),
);
}
});

View file

@ -216,10 +216,7 @@ BlazeComponent.extendComponent({
canSeeAddCard() {
return (
!this.reachedWipLimit() &&
Meteor.user() &&
Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
Utils.canModifyCard()
);
},
@ -620,7 +617,7 @@ BlazeComponent.extendComponent({
this.board = {};
if (this.isTemplateSearch) {
const boardId = (Meteor.user().profile || {}).templatesBoardId;
const boardId = (ReactiveCache.getCurrentUser().profile || {}).templatesBoardId;
if (boardId) {
this.board = ReactiveCache.getBoard(boardId);
}
@ -789,7 +786,7 @@ BlazeComponent.extendComponent({
Meteor.settings.public.sandstorm;
if (isSandstorm) {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
if (user) {
if (Utils.boardView() === 'board-view-swimlanes') {
this.swimlaneId = this.parentComponent()

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
let listsColors;
@ -12,12 +13,12 @@ BlazeComponent.extendComponent({
(!list.getWipLimit('enabled') ||
list.getWipLimit('soft') ||
!this.reachedWipLimit()) &&
!Meteor.user().isWorker()
!ReactiveCache.getCurrentUser().isWorker()
);
},
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
starred(check = undefined) {
const list = Template.currentData();
@ -47,9 +48,9 @@ BlazeComponent.extendComponent({
},
limitToShowCardsCount() {
const currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return Meteor.user().getLimitToShowCardsCount();
return currentUser.getLimitToShowCardsCount();
} else {
return false;
}
@ -123,13 +124,13 @@ BlazeComponent.extendComponent({
Template.listHeader.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
}
});
Template.listActionPopup.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
isWipLimitEnabled() {
@ -279,7 +280,7 @@ Template.listMorePopup.events({
Template.listHeader.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
});