Skip to content

Commit

Permalink
fix for communicator builder
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbedouret committed Dec 14, 2019
1 parent 22ca5fe commit 5cb7c58
Showing 1 changed file with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,26 +302,25 @@ class CommunicatorDialogContainer extends React.Component {
userData,
communicators,
currentCommunicator,
changeCommunicator
changeCommunicator,
editCommunicator
} = this.props;

const updatedCommunicatorData = {
...currentCommunicator,
boards: boards.map(cb => cb.id)
};

const action =
communicators.findIndex(c => c.id === currentCommunicator.id) >= 0
? 'editCommunicator'
: 'createCommunicator';
this.props[action](updatedCommunicatorData);
changeCommunicator(updatedCommunicatorData.id);
if (communicators.findIndex(c => c.id === currentCommunicator.id) >= 0) {
editCommunicator(updatedCommunicatorData);
changeCommunicator(updatedCommunicatorData.id);

// Loggedin user?
if ('name' in userData && 'email' in userData) {
try {
await API.updateCommunicator(updatedCommunicatorData);
} catch (err) {}
// Loggedin user?
if ('name' in userData && 'email' in userData) {
try {
await API.updateCommunicator(updatedCommunicatorData);
} catch (err) {}
}
}
}

Expand All @@ -343,22 +342,30 @@ class CommunicatorDialogContainer extends React.Component {
}

async setRootBoard(board) {
const {
userData,
communicators,
currentCommunicator,
changeCommunicator,
editCommunicator
} = this.props;

const updatedCommunicatorData = {
...this.props.currentCommunicator,
...currentCommunicator,
rootBoard: board.id
};

const communicatorData = await API.updateCommunicator(
updatedCommunicatorData
);
if (communicators.findIndex(c => c.id === currentCommunicator.id) >= 0) {
editCommunicator(updatedCommunicatorData);
changeCommunicator(updatedCommunicatorData.id);

const action =
this.props.communicators.findIndex(c => c.id === communicatorData.id) >= 0
? 'editCommunicator'
: 'createCommunicator';
this.props[action](communicatorData);
this.props.changeCommunicator(communicatorData.id);
return communicatorData;
// Loggedin user?
if ('name' in userData && 'email' in userData) {
try {
await API.updateCommunicator(updatedCommunicatorData);
} catch (err) {}
}
}
}

openSearchBar() {
Expand Down

0 comments on commit 5cb7c58

Please sign in to comment.