refactor: make a single call to set widgets per template

This commit is contained in:
Barış Soner Uşaklı
2021-11-10 20:40:34 -05:00
parent 80f9963bed
commit 8750ee04a6
2 changed files with 22 additions and 5 deletions

View File

@@ -1,14 +1,12 @@
'use strict';
const async = require('async');
const widgets = require('../../widgets');
const Widgets = module.exports;
Widgets.set = function (socket, data, callback) {
Widgets.set = async function (socket, data) {
if (!Array.isArray(data)) {
return callback(new Error('[[error:invalid-data]]'));
throw new Error('[[error:invalid-data]]');
}
async.eachSeries(data, widgets.setArea, callback);
await widgets.setAreas(data);
};