mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Don’t resolve mods when saving servers
This commit is contained in:
parent
8c3cf2abbe
commit
1e0b7bddbb
18
lib/mods.js
18
lib/mods.js
@ -14,13 +14,6 @@ var Mods = function (config) {
|
||||
var self = this;
|
||||
};
|
||||
|
||||
Mods.removeDuplicates = function (mods) {
|
||||
return mods.reduce(function(a,b){
|
||||
if (a.indexOf(b) < 0 ) a.push(b);
|
||||
return a;
|
||||
},[]);
|
||||
};
|
||||
|
||||
Mods.prototype = new events.EventEmitter();
|
||||
|
||||
Mods.prototype.delete = function (mod, cb) {
|
||||
@ -122,17 +115,6 @@ Mods.prototype.isPlayWithSixMod = function (modPath, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
Mods.prototype.resolveMods = function (modsToResolve, cb) {
|
||||
var self = this;
|
||||
playwithsix.resolveDependencies(modsToResolve, {lite: this.liteMods}, function (err, mods) {
|
||||
if (!err && mods) {
|
||||
cb(null, Mods.removeDuplicates(modsToResolve.concat(mods)));
|
||||
} else {
|
||||
cb(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Mods.prototype.search = function (query, cb) {
|
||||
playwithsix.search(query, function (err, mods) {
|
||||
if (err) {
|
||||
|
@ -1,14 +1,4 @@
|
||||
module.exports = function (manager, mods) {
|
||||
var resolveMods = function(server, cb) {
|
||||
mods.resolveMods(server.mods, function(err, resolvedMods) {
|
||||
if (!err) {
|
||||
server.mods = resolvedMods;
|
||||
manager.save();
|
||||
}
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
index: function (req, res){
|
||||
res.send(manager.getServers());
|
||||
@ -16,13 +6,7 @@ module.exports = function (manager, mods) {
|
||||
|
||||
create: function (req, res) {
|
||||
var server = manager.addServer(req.body);
|
||||
if (server.mods.length > 0) {
|
||||
resolveMods(server, function() {
|
||||
res.send(server);
|
||||
});
|
||||
} else {
|
||||
res.send(server);
|
||||
}
|
||||
res.send(server);
|
||||
},
|
||||
|
||||
show: function (req, res){
|
||||
@ -34,14 +18,7 @@ module.exports = function (manager, mods) {
|
||||
var server = manager.getServer(req.params.server);
|
||||
server.update(req.body);
|
||||
manager.save();
|
||||
|
||||
if (server.mods.length > 0) {
|
||||
resolveMods(server, function() {
|
||||
res.send(server);
|
||||
});
|
||||
} else {
|
||||
res.send(server);
|
||||
}
|
||||
res.send(server);
|
||||
},
|
||||
|
||||
destroy: function(req, res){
|
||||
|
@ -3,12 +3,6 @@ var should = require('should');
|
||||
var Mods = require('../../lib/mods.js');
|
||||
|
||||
describe('Mods', function() {
|
||||
describe('removeDuplicates()', function() {
|
||||
it('should remove duplicate mods', function() {
|
||||
Mods.removeDuplicates(['mod1', 'mod1']).should.eql(['mod1']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('search()', function() {
|
||||
it('should find mods', function(done) {
|
||||
var mods = new Mods();
|
||||
|
Loading…
Reference in New Issue
Block a user