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

@ -25,7 +25,7 @@ BlazeComponent.extendComponent({
searchId = Session.get(`current${capitalizedMode}`);
}
const limit = this.page.get() * activitiesPerPage;
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
const hideSystem = user ? user.hasHiddenSystemMessages() : false;
if (searchId === null) return;
@ -283,7 +283,7 @@ Template.activity.helpers({
Template.commentReactions.events({
'click .reaction'(event) {
if (Meteor.user().isBoardMember()) {
if (ReactiveCache.getCurrentUser().isBoardMember()) {
const codepoint = event.currentTarget.dataset['codepoint'];
const commentId = Template.instance().data.commentId;
const cardComment = CardComments.findOne({_id: commentId});
@ -295,7 +295,7 @@ Template.commentReactions.events({
Template.addReactionPopup.events({
'click .add-comment-reaction'(event) {
if (Meteor.user().isBoardMember()) {
if (ReactiveCache.getCurrentUser().isBoardMember()) {
const codepoint = event.currentTarget.dataset['codepoint'];
const commentId = Template.instance().data.commentId;
const cardComment = CardComments.findOne({_id: commentId});
@ -326,7 +326,7 @@ Template.addReactionPopup.helpers({
Template.commentReactions.helpers({
isSelected(userIds) {
return userIds.includes(Meteor.user()._id);
return Meteor.userId() && userIds.includes(Meteor.userId());
},
userNames(userIds) {
return Users.find({_id: {$in: userIds}})

View file

@ -1,10 +1,12 @@
import { ReactiveCache } from '/imports/reactiveCache';
BlazeComponent.extendComponent({
onCreated() {
this.subscribe('archivedBoards');
},
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
archivedBoards() {

View file

@ -205,11 +205,10 @@ BlazeComponent.extendComponent({
}
// Disable drag-dropping if the current user is not a board member
//$swimlanesDom.sortable('option', 'disabled', !userIsMember());
$swimlanesDom.sortable(
'option',
'disabled',
!Meteor.user() || !Meteor.user().isBoardAdmin(),
!ReactiveCache.getCurrentUser()?.isBoardAdmin(),
);
});
@ -232,7 +231,7 @@ BlazeComponent.extendComponent({
},
isViewSwimlanes() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-swimlanes';
} else {
@ -243,7 +242,7 @@ BlazeComponent.extendComponent({
},
isViewLists() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-lists';
} else {
@ -252,7 +251,7 @@ BlazeComponent.extendComponent({
},
isViewCalendar() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-cal';
} else {
@ -418,7 +417,7 @@ BlazeComponent.extendComponent({
},
select: function(startDate) {
const currentBoard = Utils.getCurrentBoard();
const currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
const $modal = $(`
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog justify-content-center align-items-center" role="document">
@ -459,7 +458,7 @@ BlazeComponent.extendComponent({
};
},
isViewCalendar() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).boardView === 'board-view-cal';
} else {

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
/*
@ -64,7 +65,7 @@ BlazeComponent.extendComponent({
isStarred() {
const boardId = Session.get('currentBoard');
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
return user && user.hasStarred(boardId);
},
@ -75,7 +76,7 @@ BlazeComponent.extendComponent({
},
/*
showSort() {
return Meteor.user().hasSortBy();
return ReactiveCache.getCurrentUser().hasSortBy();
},
directionClass() {
return this.currentDirection() === -1 ? DOWNCLS : UPCLS;
@ -85,10 +86,10 @@ BlazeComponent.extendComponent({
Meteor.call('setListSortBy', direction + this.currentListSortBy());
},
currentDirection() {
return Meteor.user().getListSortByDirection();
return ReactiveCache.getCurrentUser().getListSortByDirection();
},
currentListSortBy() {
return Meteor.user().getListSortBy();
return ReactiveCache.getCurrentUser().getListSortBy();
},
listSortShortDesc() {
return `list-label-short-${this.currentListSortBy()}`;
@ -99,7 +100,7 @@ BlazeComponent.extendComponent({
{
'click .js-edit-board-title': Popup.open('boardChangeTitle'),
'click .js-star-board'() {
Meteor.user().toggleBoardStar(Session.get('currentBoard'));
ReactiveCache.getCurrentUser().toggleBoardStar(Session.get('currentBoard'));
},
'click .js-open-board-menu': Popup.open('boardMenu'),
'click .js-change-visibility': Popup.open('boardChangeVisibility'),
@ -306,7 +307,7 @@ const CreateBoard = BlazeComponent.extendComponent({
onSubmit(event) {
super.onSubmit(event);
// Immediately star boards crated with the headerbar popup.
Meteor.user().toggleBoardStar(this.boardId.get());
ReactiveCache.getCurrentUser().toggleBoardStar(this.boardId.get());
}
}.register('headerBarCreateBoardPopup'));
@ -377,7 +378,7 @@ BlazeComponent.extendComponent({
allowedSortValues() {
const types = [];
const pushed = {};
Meteor.user()
ReactiveCache.getCurrentUser()
.getListSortTypes()
.forEach(type => {
const key = type.replace(/^-/, '');
@ -393,16 +394,16 @@ BlazeComponent.extendComponent({
return types;
},
Direction() {
return Meteor.user().getListSortByDirection() === -1
return ReactiveCache.getCurrentUser().getListSortByDirection() === -1
? this.downClass
: this.upClass;
},
sortby() {
return Meteor.user().getListSortBy();
return ReactiveCache.getCurrentUser().getListSortBy();
},
setSortBy(type = null) {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
if (type === null) {
type = user._getListSortBy();
} else {

View file

@ -31,10 +31,10 @@ Template.boardListHeaderBar.helpers({
//}
},
templatesBoardId() {
return Meteor.user() && Meteor.user().getTemplatesBoardId();
return ReactiveCache.getCurrentUser()?.getTemplatesBoardId();
},
templatesBoardSlug() {
return Meteor.user() && Meteor.user().getTemplatesBoardSlug();
return ReactiveCache.getCurrentUser()?.getTemplatesBoardSlug();
},
});
@ -42,7 +42,7 @@ BlazeComponent.extendComponent({
onCreated() {
Meteor.subscribe('setting');
Meteor.subscribe('tableVisibilityModeSettings');
let currUser = Meteor.user();
let currUser = ReactiveCache.getCurrentUser();
let userLanguage;
if (currUser && currUser.profile) {
userLanguage = currUser.profile.language
@ -100,51 +100,34 @@ BlazeComponent.extendComponent({
});
},
userHasTeams() {
if (Meteor.user() != null && Meteor.user().teams && Meteor.user().teams.length > 0)
if (ReactiveCache.getCurrentUser()?.teams?.length > 0)
return true;
else
return false;
},
teamsDatas() {
if (Meteor.user().teams)
return Meteor.user().teams.sort((a, b) => a.teamDisplayName.localeCompare(b.teamDisplayName));
const teams = ReactiveCache.getCurrentUser()?.teams
if (teams)
return teams.sort((a, b) => a.teamDisplayName.localeCompare(b.teamDisplayName));
else
return [];
},
userHasOrgs() {
if (Meteor.user() != null && Meteor.user().orgs && Meteor.user().orgs.length > 0)
if (ReactiveCache.getCurrentUser()?.orgs?.length > 0)
return true;
else
return false;
},
/*
userHasTemplates(){
if(Meteor.user() != null && Meteor.user().orgs && Meteor.user().orgs.length > 0)
return true;
else
return false;
},
*/
orgsDatas() {
if (Meteor.user().orgs)
return Meteor.user().orgs.sort((a, b) => a.orgDisplayName.localeCompare(b.orgDisplayName));
const orgs = ReactiveCache.getCurrentUser()?.orgs;
if (orgs)
return orgs.sort((a, b) => a.orgDisplayName.localeCompare(b.orgDisplayName));
else
return [];
},
userHasOrgsOrTeams() {
let boolUserHasOrgs;
if (Meteor.user() != null && Meteor.user().orgs && Meteor.user().orgs.length > 0)
boolUserHasOrgs = true;
else
boolUserHasOrgs = false;
let boolUserHasTeams;
if (Meteor.user() != null && Meteor.user().teams && Meteor.user().teams.length > 0)
boolUserHasTeams = true;
else
boolUserHasTeams = false;
return (boolUserHasOrgs || boolUserHasTeams);
const ret = this.userHasOrgs() || this.userHasTeams();
return ret;
},
boards() {
let query = {
@ -227,11 +210,11 @@ BlazeComponent.extendComponent({
},
isStarred() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
return user && user.hasStarred(this.currentData()._id);
},
isAdministrable() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
return user && user.isBoardAdmin(this.currentData()._id);
},
@ -246,7 +229,7 @@ BlazeComponent.extendComponent({
},
isInvited() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
return user && user.isInvitedTo(this.currentData()._id);
},
@ -256,7 +239,7 @@ BlazeComponent.extendComponent({
'click .js-add-board': Popup.open('createBoard'),
'click .js-star-board'(evt) {
const boardId = this.currentData()._id;
Meteor.user().toggleBoardStar(boardId);
ReactiveCache.getCurrentUser().toggleBoardStar(boardId);
evt.preventDefault();
},
'click .js-clone-board'(evt) {

View file

@ -167,7 +167,7 @@ Template.attachmentViewer.events({
Template.attachmentGallery.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
fileSize(size) {
const ret = filesize(size);

View file

@ -64,16 +64,16 @@ BlazeComponent.extendComponent({
},
hiddenSystemMessages() {
return Meteor.user().hasHiddenSystemMessages();
return ReactiveCache.getCurrentUser().hasHiddenSystemMessages();
},
customFieldsGrid() {
return Meteor.user().hasCustomFieldsGrid();
return ReactiveCache.getCurrentUser().hasCustomFieldsGrid();
},
cardMaximized() {
return !Utils.getPopupCardId() && Meteor.user().hasCardMaximized();
return !Utils.getPopupCardId() && ReactiveCache.getCurrentUser().hasCardMaximized();
},
scrollParentContainer() {
@ -193,7 +193,7 @@ BlazeComponent.extendComponent({
cardId: card._id,
boardId: card.boardId,
listId: card.listId,
user: Meteor.user().username,
user: ReactiveCache.getCurrentUser().username,
url: '',
};
@ -288,7 +288,7 @@ BlazeComponent.extendComponent({
});
function userIsMember() {
return Meteor.user() && Meteor.user().isBoardMember();
return ReactiveCache.getCurrentUser()?.isBoardMember();
}
// Disable sorting if the current user is not a board member
@ -652,7 +652,7 @@ Template.cardDetailsActionsPopup.helpers({
},
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
});
@ -814,11 +814,11 @@ Template.editCardAssignerForm.events({
/** Move Card Dialog */
(class extends DialogWithBoardSwimlaneList {
getDialogOptions() {
const ret = Meteor.user().getMoveAndCopyDialogOptions();
const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
return ret;
}
setDone(boardId, swimlaneId, listId, options) {
Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
const card = this.data();
const minOrder = card.getMinSort(listId, swimlaneId);
card.move(boardId, swimlaneId, listId, minOrder - 1);
@ -828,11 +828,11 @@ Template.editCardAssignerForm.events({
/** Copy Card Dialog */
(class extends DialogWithBoardSwimlaneList {
getDialogOptions() {
const ret = Meteor.user().getMoveAndCopyDialogOptions();
const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
return ret;
}
setDone(boardId, swimlaneId, listId, options) {
Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
const card = this.data();
// const textarea = $('#copy-card-title');
@ -855,11 +855,11 @@ Template.editCardAssignerForm.events({
/** Convert Checklist-Item to card dialog */
(class extends DialogWithBoardSwimlaneList {
getDialogOptions() {
const ret = Meteor.user().getMoveAndCopyDialogOptions();
const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
return ret;
}
setDone(boardId, swimlaneId, listId, options) {
Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
const card = this.data();
const textarea = this.$('#copy-card-title');
@ -885,11 +885,11 @@ Template.editCardAssignerForm.events({
/** Copy many cards dialog */
(class extends DialogWithBoardSwimlaneList {
getDialogOptions() {
const ret = Meteor.user().getMoveAndCopyDialogOptions();
const ret = ReactiveCache.getCurrentUser().getMoveAndCopyDialogOptions();
return ret;
}
setDone(boardId, swimlaneId, listId, options) {
Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
ReactiveCache.getCurrentUser().setMoveAndCopyDialogOption(this.currentBoardId, options);
const card = this.data();
const textarea = this.$('#copy-card-title');
@ -966,7 +966,7 @@ BlazeComponent.extendComponent({
archived: false,
'members.userId': Meteor.userId(),
_id: {
$ne: Meteor.user().getTemplatesBoardId(),
$ne: ReactiveCache.getCurrentUser().getTemplatesBoardId(),
},
},
{
@ -1563,8 +1563,8 @@ EscapeActions.register(
() => {
// if card description diverges from database due to editing
// ask user whether changes should be applied
if (Meteor.user()) {
if (Meteor.user().profile.rescueCardDescription == true) {
if (ReactiveCache.getCurrentUser()) {
if (ReactiveCache.getCurrentUser().profile.rescueCardDescription == true) {
currentDescription = document.getElementsByClassName("editor js-new-description-input").item(0)
if (currentDescription?.value && !(currentDescription.value === Utils.getCurrentCard().getDescription())) {
if (confirm(TAPi18n.__('rescue-card-description-dialogue'))) {

View file

@ -55,7 +55,7 @@ BlazeComponent.extendComponent({
});
function userIsMember() {
return Meteor.user() && Meteor.user().isBoardMember();
return ReactiveCache.getCurrentUser()?.isBoardMember();
}
// Disable sorting if the current user is not a board member
@ -237,7 +237,7 @@ BlazeComponent.extendComponent({
{
archived: false,
'members.userId': Meteor.userId(),
_id: { $ne: Meteor.user().getTemplatesBoardId() },
_id: { $ne: ReactiveCache.getCurrentUser().getTemplatesBoardId() },
},
{
sort: { sort: 1 /* boards default sorting */ },
@ -274,7 +274,7 @@ Template.checklists.helpers({
return ret;
},
hideCheckedItems() {
const currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) return currentUser.hasHideCheckedItems();
return false;
},
@ -338,7 +338,7 @@ BlazeComponent.extendComponent({
Template.checklistItemDetail.helpers({
hideCheckedItems() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
if (user) return user.hasHideCheckedItems();
return false;
},
@ -364,11 +364,11 @@ BlazeComponent.extendComponent({
/** Move Checklist Dialog */
(class extends DialogWithBoardSwimlaneListCard {
getDialogOptions() {
const ret = Meteor.user().getMoveChecklistDialogOptions();
const ret = ReactiveCache.getCurrentUser().getMoveChecklistDialogOptions();
return ret;
}
setDone(cardId, options) {
Meteor.user().setMoveChecklistDialogOption(this.currentBoardId, options);
ReactiveCache.getCurrentUser().setMoveChecklistDialogOption(this.currentBoardId, options);
this.data().checklist.move(cardId);
}
}).register('moveChecklistPopup');
@ -376,11 +376,11 @@ BlazeComponent.extendComponent({
/** Copy Checklist Dialog */
(class extends DialogWithBoardSwimlaneListCard {
getDialogOptions() {
const ret = Meteor.user().getCopyChecklistDialogOptions();
const ret = ReactiveCache.getCurrentUser().getCopyChecklistDialogOptions();
return ret;
}
setDone(cardId, options) {
Meteor.user().setCopyChecklistDialogOption(this.currentBoardId, options);
ReactiveCache.getCurrentUser().setCopyChecklistDialogOption(this.currentBoardId, options);
this.data().checklist.copy(cardId);
}
}).register('copyChecklistPopup');

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
import { CustomFieldStringTemplate } from '/client/lib/customFields'
@ -113,7 +114,7 @@ BlazeComponent.extendComponent({
Template.minicard.helpers({
hiddenMinicardLabelText() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).hiddenMinicardLabelText;
} else if (window.localStorage.getItem('hiddenMinicardLabelText')) {

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();
},
});

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { CardSearchPagedComponent } from '../../lib/cardSearch';
import {
OPERATOR_HAS,
@ -66,7 +67,7 @@ class DueCardsComponent extends CardSearchPagedComponent {
});
if (Utils.dueCardsView() !== 'all') {
queryParams.addPredicate(OPERATOR_USER, Meteor.user().username);
queryParams.addPredicate(OPERATOR_USER, ReactiveCache.getCurrentUser().username);
}
this.runGlobalSearch(queryParams);

View file

@ -51,7 +51,7 @@ Template.userFormsLayout.onCreated(function () {
}
});
if (!Meteor.user()?.profile) {
if (!ReactiveCache.getCurrentUser()?.profile) {
Meteor.call('isOidcRedirectionEnabled', (_, result) => {
if (result) {
AccountsTemplates.options.socialLoginStyle = 'redirect';

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
Template.notification.events({
'click .read-status .materialCheckBox'() {
const update = {};
@ -7,7 +9,7 @@ Template.notification.events({
Users.update(Meteor.userId(), { $set: update });
},
'click .remove a'() {
Meteor.user().removeNotification(this.activityData._id);
ReactiveCache.getCurrentUser().removeNotification(this.activityData._id);
},
});

View file

@ -19,7 +19,7 @@ Template.notificationsDrawer.helpers({
},
readNotifications() {
const readNotifications = _.filter(
Meteor.user().profile.notifications,
ReactiveCache.getCurrentUser().profile.notifications,
v => !!v.read,
);
return readNotifications.length;
@ -28,7 +28,7 @@ Template.notificationsDrawer.helpers({
Template.notificationsDrawer.events({
'click .all-read'() {
const notifications = Meteor.user().profile.notifications;
const notifications = ReactiveCache.getCurrentUser().profile.notifications;
for (const index in notifications) {
if (notifications.hasOwnProperty(index) && !notifications[index].read) {
const update = {};
@ -44,7 +44,7 @@ Template.notificationsDrawer.events({
Session.set('showReadNotifications', !Session.get('showReadNotifications'));
},
'click .remove-read'() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
for (const notification of user.profile.notifications) {
if (notification.read) {
user.removeNotification(notification.activity);

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
BlazeComponent.extendComponent({
onCreated() {},
@ -7,7 +9,7 @@ BlazeComponent.extendComponent({
archived: false,
'members.userId': Meteor.userId(),
_id: {
$ne: Meteor.user().getTemplatesBoardId(),
$ne: ReactiveCache.getCurrentUser().getTemplatesBoardId(),
},
},
{

View file

@ -112,7 +112,7 @@ BlazeComponent.extendComponent({
'click .js-toggle-sidebar': this.toggle,
'click .js-back-home': this.setView,
'click .js-toggle-minicard-label-text'() {
currentUser = Meteor.user();
currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
Meteor.call('toggleMinicardLabelText');
} else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
@ -138,7 +138,7 @@ Blaze.registerHelper('Sidebar', () => Sidebar);
Template.homeSidebar.helpers({
hiddenMinicardLabelText() {
currentUser = Meteor.user();
currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).hiddenMinicardLabelText;
} else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
@ -173,7 +173,7 @@ Template.memberPopup.helpers({
return ReactiveCache.getUser(this.userId);
},
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
memberType() {
const type = ReactiveCache.getUser(this.userId).isBoardAdmin() ? 'admin' : 'normal';
@ -249,7 +249,7 @@ Template.boardMenuPopup.onCreated(function() {
Template.boardMenuPopup.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
withApi() {
return Template.instance().apiEnabled.get();
@ -359,11 +359,11 @@ BlazeComponent.extendComponent({
Template.membersWidget.helpers({
isInvited() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
return user && user.isInvitedTo(Session.get('currentBoard'));
},
isWorker() {
const user = Meteor.user();
const user = ReactiveCache.getCurrentUser();
if (user) {
return Meteor.call(Boards.hasWorker(user.memberId));
} else {
@ -371,7 +371,7 @@ Template.membersWidget.helpers({
}
},
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
AtLeastOneOrgWasCreated(){
let orgs = Org.find({}, {sort: { createdAt: -1 }});
@ -407,13 +407,13 @@ Template.membersWidget.events({
},
'click .js-member-invite-accept'() {
const boardId = Session.get('currentBoard');
Meteor.user().removeInvite(boardId);
ReactiveCache.getCurrentUser().removeInvite(boardId);
},
'click .js-member-invite-decline'() {
const boardId = Session.get('currentBoard');
Meteor.call('quitBoard', boardId, (err, ret) => {
if (!err && ret) {
Meteor.user().removeInvite(boardId);
ReactiveCache.getCurrentUser().removeInvite(boardId);
FlowRouter.go('home');
}
});
@ -605,7 +605,7 @@ Template.labelsWidget.events({
Template.labelsWidget.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
});
@ -640,7 +640,7 @@ function draggableMembersLabelsWidgets() {
});
function userIsMember() {
return Meteor.user() && Meteor.user().isBoardMember();
return ReactiveCache.getCurrentUser()?.isBoardMember();
}
this.autorun(() => {

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
//archivedRequested = false;
@ -159,7 +160,7 @@ BlazeComponent.extendComponent({
Template.archivesSidebar.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
isWorker() {
const currentBoard = Utils.getCurrentBoard();

View file

@ -1,3 +1,5 @@
import { ReactiveCache } from '/imports/reactiveCache';
const subManager = new SubsManager();
BlazeComponent.extendComponent({
@ -171,10 +173,10 @@ BlazeComponent.extendComponent({
Template.multiselectionSidebar.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
isCommentOnly() {
return Meteor.user().isCommentOnly();
return ReactiveCache.getCurrentUser().isCommentOnly();
},
});

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
const { calculateIndexData } = Utils;
let swimlaneColors;
@ -30,7 +31,7 @@ BlazeComponent.extendComponent({
Template.swimlaneFixedHeader.helpers({
isBoardAdmin() {
return Meteor.user().isBoardAdmin();
return ReactiveCache.getCurrentUser().isBoardAdmin();
},
});
@ -47,7 +48,7 @@ Template.swimlaneActionPopup.events({
Template.swimlaneActionPopup.events({
isCommentOnly() {
return Meteor.user().isCommentOnly();
return ReactiveCache.getCurrentUser().isCommentOnly();
},
});

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
const { calculateIndex } = Utils;
function currentListIsInThisSwimlane(swimlaneId) {
@ -10,7 +11,7 @@ function currentListIsInThisSwimlane(swimlaneId) {
function currentCardIsInThisList(listId, swimlaneId) {
const currentCard = Utils.getCurrentCard();
//const currentUser = Meteor.user();
//const currentUser = ReactiveCache.getCurrentUser();
if (
//currentUser &&
//currentUser.profile &&
@ -104,15 +105,6 @@ function initSortable(boardComponent, $listsDom) {
},
});
//function userIsMember() {
// return (
// Meteor.user() &&
// Meteor.user().isBoardMember() &&
// !Meteor.user().isCommentOnly() &&
// !Meteor.user().isWorker()
// );
//}
boardComponent.autorun(() => {
if (Utils.isTouchScreenOrShowDesktopDragHandles()) {
$listsDom.sortable({
@ -129,11 +121,7 @@ function initSortable(boardComponent, $listsDom) {
$listsDom.sortable(
'option',
'disabled',
// Disable drag-dropping when user is not member/is worker
//!userIsMember() || Meteor.user().isWorker(),
!Meteor.user() || !Meteor.user().isBoardAdmin(),
// Not disable drag-dropping while in multi-selection mode
// MultiSelection.isActive() || !userIsMember(),
!ReactiveCache.getCurrentUser()?.isBoardAdmin(),
);
}
});
@ -294,12 +282,6 @@ BlazeComponent.extendComponent({
Template.swimlane.helpers({
canSeeAddList() {
return Meteor.user().isBoardAdmin();
/*
Meteor.user() &&
Meteor.user().isBoardMember() &&
!Meteor.user().isCommentOnly() &&
!Meteor.user().isWorker()
*/
},
});

View file

@ -91,9 +91,6 @@ Template.boardOrgRow.helpers({
orgData() {
return Org.findOne(this.orgId);
},
currentUser(){
return Meteor.user();
},
});
Template.boardOrgName.helpers({
@ -153,9 +150,6 @@ Template.boardTeamRow.helpers({
teamData() {
return Team.findOne(this.teamId);
},
currentUser(){
return Meteor.user();
},
});
Template.boardTeamName.helpers({
@ -182,20 +176,20 @@ BlazeComponent.extendComponent({
},
isSelected() {
const userProfile = Meteor.user().profile;
const userProfile = ReactiveCache.getCurrentUser().profile;
const avatarUrl = userProfile && userProfile.avatarUrl;
const currentAvatarUrl = `${this.currentData().link()}?auth=false&brokenIsFine=true`;
return avatarUrl === currentAvatarUrl;
},
noAvatarUrl() {
const userProfile = Meteor.user().profile;
const userProfile = ReactiveCache.getCurrentUser().profile;
const avatarUrl = userProfile && userProfile.avatarUrl;
return !avatarUrl;
},
setAvatar(avatarUrl) {
Meteor.user().setAvatarUrl(avatarUrl);
ReactiveCache.getCurrentUser().setAvatarUrl(avatarUrl);
},
setError(error) {

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
Template.headerUserBar.events({
@ -13,18 +14,18 @@ BlazeComponent.extendComponent({
Template.memberMenuPopup.helpers({
templatesBoardId() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return Meteor.user().getTemplatesBoardId();
return currentUser.getTemplatesBoardId();
} else {
// No need to getTemplatesBoardId on public board
return false;
}
},
templatesBoardSlug() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return Meteor.user().getTemplatesBoardSlug();
return currentUser.getTemplatesBoardSlug();
} else {
// No need to getTemplatesBoardSlug() on public board
return false;
@ -33,7 +34,7 @@ Template.memberMenuPopup.helpers({
isSameDomainNameSettingValue(){
const currSett = Utils.getCurrentSetting();
if(currSett && currSett != undefined && currSett.disableRegistration && currSett.mailDomainName !== undefined && currSett.mailDomainName != ""){
currentUser = Meteor.user();
currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
let found = false;
for(let i = 0; i < currentUser.emails.length; i++) {
@ -51,7 +52,7 @@ Template.memberMenuPopup.helpers({
return false;
},
isNotOAuth2AuthenticationMethod(){
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return currentUser.authenticationMethod.toLowerCase() != 'oauth2';
} else {
@ -185,9 +186,9 @@ Template.editProfilePopup.events({
'profile.initials': initials,
},
});
isChangeUserName = username !== Meteor.user().username;
isChangeUserName = username !== ReactiveCache.getCurrentUser().username;
isChangeEmail =
email.toLowerCase() !== Meteor.user().emails[0].address.toLowerCase();
email.toLowerCase() !== ReactiveCache.getCurrentUser().emails[0].address.toLowerCase();
if (isChangeUserName && isChangeEmail) {
Meteor.call(
'setUsernameAndEmail',
@ -282,7 +283,7 @@ Template.changeLanguagePopup.events({
Template.changeSettingsPopup.helpers({
hiddenSystemMessages() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).hasHiddenSystemMessages;
} else if (window.localStorage.getItem('hasHiddenSystemMessages')) {
@ -292,7 +293,7 @@ Template.changeSettingsPopup.helpers({
}
},
rescueCardDescription() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return (currentUser.profile || {}).rescueCardDescription;
} else if (window.localStorage.getItem('rescueCardDescription')) {
@ -302,9 +303,9 @@ Template.changeSettingsPopup.helpers({
}
},
showCardsCountAt() {
currentUser = Meteor.user();
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
return Meteor.user().getLimitToShowCardsCount();
return currentUser.getLimitToShowCardsCount();
} else {
return window.localStorage.getItem('limitToShowCardsCount');
}