mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #9827, fix reward duplication
This commit is contained in:
@@ -167,11 +167,17 @@ define('admin/extend/rewards', [], function () {
|
||||
activeRewards.push(data);
|
||||
});
|
||||
|
||||
socket.emit('admin.rewards.save', activeRewards, function (err) {
|
||||
socket.emit('admin.rewards.save', activeRewards, function (err, result) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
} else {
|
||||
app.alertSuccess('[[admin/extend/rewards:alert.save-success]]');
|
||||
// newly added rewards are missing data-id, update to prevent rewards getting duplicated
|
||||
$('#active li').each(function (index) {
|
||||
if (!$(this).attr('data-id')) {
|
||||
$(this).attr('data-id', result[index].id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ rewards.save = async function (data) {
|
||||
|
||||
await Promise.all(data.map(data => save(data)));
|
||||
await saveConditions(data);
|
||||
return data;
|
||||
};
|
||||
|
||||
rewards.delete = async function (data) {
|
||||
|
||||
@@ -5,7 +5,7 @@ const rewardsAdmin = require('../../rewards/admin');
|
||||
const SocketRewards = module.exports;
|
||||
|
||||
SocketRewards.save = async function (socket, data) {
|
||||
await rewardsAdmin.save(data);
|
||||
return await rewardsAdmin.save(data);
|
||||
};
|
||||
|
||||
SocketRewards.delete = async function (socket, data) {
|
||||
|
||||
Reference in New Issue
Block a user