saveLocalMoodsData(moodboard) {
const {hoc_methods} = this.props;
return new Promise((resolve, reject) => {
this.showAuthPopup({
callback: () => {
hoc_methods.saveLocalMoods(moodboard.id).then(payload => {
hoc_methods.closeModal();
const mood = safeGet(payload, 'payload', {});
const data = {...mood, count: mood.blocks.length};
// reject при ошибке, если она возможна
resolve(data);
})
}
})
});
}
addCardToMoodboard(moodboard, cardData) {
if (moodboard.localMode) {
return saveLocalMoodsData(moodboard)
.then(data => this.addCardToMood(data, cardData));
} else {
return this.addCardToMood(moodboard, cardData);
}
}