nodebb-plugin-poll
Advanced tools
Comparing version 3.1.2 to 3.1.3
@@ -35,10 +35,21 @@ 'use strict'; | ||
// async this bitch up | ||
// Save asynchronously | ||
async.parallel([ | ||
async.apply(async.each, pollData.options, (option, next) => { | ||
async.series([ | ||
async.apply(NodeBB.db.setObject, `poll:${pollId}:options:${option.id}`, option), | ||
async.apply(NodeBB.db.setAdd, `poll:${pollId}:options`, option.id), | ||
], next); | ||
}), | ||
async.apply(async.series, [ | ||
// Save poll options in parallel | ||
async.apply( | ||
async.parallel, | ||
pollData.options.map( | ||
(option) => async.apply(NodeBB.db.setObject, `poll:${pollId}:options:${option.id}`, option) | ||
), | ||
), | ||
// Add poll option id to option list synchronously | ||
// To avoid race condition causing duplicate error | ||
async.apply( | ||
async.series, | ||
pollData.options.map( | ||
(option) => async.apply(NodeBB.db.setAdd, `poll:${pollId}:options`, option.id) | ||
), | ||
), | ||
]), | ||
async.apply(NodeBB.db.setObject, `poll:${pollId}`, poll), | ||
@@ -49,2 +60,3 @@ async.apply(NodeBB.db.setObject, `poll:${pollId}:settings`, pollData.settings), | ||
], (err) => { | ||
if (err) { | ||
@@ -51,0 +63,0 @@ return callback(err); |
{ | ||
"name": "nodebb-plugin-poll", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"description": "NodeBB Poll Plugin", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
219211
2503