From f6c01161a02e273b87c9f6cc02d3809b997241ba Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Tue, 29 Dec 2015 18:08:24 +0100 Subject: 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 --- client/components/lists/list.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'client/components/lists') diff --git a/client/components/lists/list.js b/client/components/lists/list.js index f5410ed0..e454cb48 100644 --- a/client/components/lists/list.js +++ b/client/components/lists/list.js @@ -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(() => { -- cgit v1.2.3-1-g7c22