Fix drag and drop on Sandstorm

This bug was introduced with the introduction of fast-render in
41b23f8. With fast-render data is available instantly after the page
logging, but calls to `Meteor.userId()` still return `null` as the
user isn't authenticated on the DDP channel yet (previously the data
was loaded on DDP after user authentication). Which mean that we know
need to reactively activate Drag and Drop on user log in.

I'm not sure why I was not able to reproduce this bug outside of
Sandstorm.

Fixes #453
This commit is contained in:
Maxime Quandalle 2015-12-29 18:08:24 +01:00
parent 46bf6ef803
commit f6c01161a0
3 changed files with 27 additions and 13 deletions

View file

@ -22,9 +22,6 @@ BlazeComponent.extendComponent({
// callback, we basically solve all issues related to reactive updates. A
// comment below provides further details.
onRendered() {
if (!Meteor.user() || !Meteor.user().isBoardMember())
return;
const boardComponent = this.parentComponent();
const itemsSelector = '.js-minicard:not(.placeholder, .js-card-composer)';
const $cards = this.$('.js-minicards');
@ -85,6 +82,15 @@ BlazeComponent.extendComponent({
},
});
function userIsMember() {
return Meteor.user() && Meteor.user().isBoardMember();
}
// Disable drag-dropping if the current user is not a board member
this.autorun(() => {
$cards.sortable('option', 'disabled', !userIsMember());
});
// We want to re-run this function any time a card is added.
this.autorun(() => {
const currentBoardId = Tracker.nonreactive(() => {