don't rely on client side to increment id (duh)

v1.18.x
psychobunny 10 years ago
parent 7a8d84c011
commit def57d2926

@ -128,12 +128,10 @@ define('admin/extend/rewards', function() {
}
function newReward() {
var ul = $('#active'),
id = $('#active li').last().attr('data-id');
var ul = $('#active');
var data = {
active: [{
id: id ? parseInt(id, 10) + 1 : 0,
disabled: true,
value: '',
claimable: 1

@ -15,20 +15,24 @@ rewards.save = function(data, callback) {
var rewardsData = data.rewards;
delete data.rewards;
async.parallel([
function(next) {
rewards.delete(data, next);
},
function(next) {
db.setAdd('rewards:list', data.id, next);
},
function(next) {
db.setObject('rewards:id:' + data.id, data, next);
},
function(next) {
db.setObject('rewards:id:' + data.id + ':rewards', rewardsData, next);
}
], next);
db.incrObjectField('global', 'nextRid', function(err, id) {
data.id = id;
async.parallel([
function(next) {
rewards.delete(data, next);
},
function(next) {
db.setAdd('rewards:list', data.id, next);
},
function(next) {
db.setObject('rewards:id:' + data.id, data, next);
},
function(next) {
db.setObject('rewards:id:' + data.id + ':rewards', rewardsData, next);
}
], next);
});
}
async.each(data, save, function(err) {

Loading…
Cancel
Save