nodebb-plugin-poll 3.1.1 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/poll.js CHANGED
@@ -32,19 +32,31 @@ const Scheduler = require('./scheduler');
32
32
  title: val,
33
33
  }));
34
34
 
35
- // async this bitch up
35
+ // Save asynchronously
36
36
  async.parallel([
37
- async.apply(async.each, pollData.options, (option, next) => {
38
- async.series([
39
- async.apply(NodeBB.db.setObject, `poll:${pollId}:options:${option.id}`, option),
40
- async.apply(NodeBB.db.setAdd, `poll:${pollId}:options`, option.id),
41
- ], next);
42
- }),
37
+ async.apply(async.series, [
38
+ // Save poll options in parallel
39
+ async.apply(
40
+ async.parallel,
41
+ pollData.options.map(
42
+ (option) => async.apply(NodeBB.db.setObject, `poll:${pollId}:options:${option.id}`, option)
43
+ ),
44
+ ),
45
+ // Add poll option id to option list synchronously
46
+ // To avoid race condition causing duplicate error
47
+ async.apply(
48
+ async.series,
49
+ pollData.options.map(
50
+ (option) => async.apply(NodeBB.db.setAdd, `poll:${pollId}:options`, option.id)
51
+ ),
52
+ ),
53
+ ]),
43
54
  async.apply(NodeBB.db.setObject, `poll:${pollId}`, poll),
44
55
  async.apply(NodeBB.db.setObject, `poll:${pollId}:settings`, pollData.settings),
45
56
  async.apply(NodeBB.db.listAppend, 'polls', pollId),
46
57
  async.apply(NodeBB.db.setObjectField, `topic:${poll.tid}`, 'pollId', pollId),
47
58
  ], (err) => {
59
+
48
60
  if (err) {
49
61
  return callback(err);
50
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-poll",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "NodeBB Poll Plugin",
5
5
  "main": "library.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- <div class="poll-view" data-poll-id="{poll.info.pollId}">
1
+ <div class="poll-view mb-3" data-poll-id="{poll.info.pollId}">
2
2
  <div class="card">
3
3
  <div class="card-header">
4
4
  <h5 class="card-title mb-0">{poll.settings.title}</h5>