mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 06:37:10 -04:00
fix duble error checking
fix whitespace coding convention
This commit is contained in:
parent
8bff85cdb2
commit
f7d8f68c13
3 changed files with 49 additions and 53 deletions
|
@ -473,36 +473,36 @@ Example returns:
|
||||||
*/
|
*/
|
||||||
exports.listAllPads = function(callback)
|
exports.listAllPads = function(callback)
|
||||||
{
|
{
|
||||||
allPads = [];
|
allPads = [];
|
||||||
|
|
||||||
var defaultGroup = "g.defaultGroupName";
|
|
||||||
|
|
||||||
//get all groups
|
|
||||||
groupManager.listGroups(function (err, groups)
|
|
||||||
{
|
|
||||||
groups=groups["groupIDs"];
|
|
||||||
// if defaultGroup exists add this too, becaus ists not listed in groupManager.listGroups
|
|
||||||
groupManager.doesGroupExist(defaultGroup, function(err, exists)
|
|
||||||
{
|
|
||||||
if(exists)
|
|
||||||
{
|
|
||||||
groups.push(defaultGroup);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for(var group in groups)
|
var defaultGroup = "g.defaultGroupName";
|
||||||
{
|
|
||||||
groupManager.listPads(groups[group], function(err, pads)
|
//get all groups
|
||||||
{
|
groupManager.listGroups(function (err, groups)
|
||||||
for(var pad in pads["padIDs"])
|
{
|
||||||
{
|
groups=groups["groupIDs"];
|
||||||
allPads.push(pads["padIDs"][pad]);
|
// if defaultGroup exists add this too, becaus ists not listed in groupManager.listGroups
|
||||||
}
|
groupManager.doesGroupExist(defaultGroup, function(err, exists)
|
||||||
});
|
{
|
||||||
}
|
if(exists)
|
||||||
|
{
|
||||||
|
groups.push(defaultGroup);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(null, {padIDs: allPads});
|
for(var group in groups)
|
||||||
|
{
|
||||||
|
groupManager.listPads(groups[group], function(err, pads)
|
||||||
|
{
|
||||||
|
for(var pad in pads["padIDs"])
|
||||||
|
{
|
||||||
|
allPads.push(pads["padIDs"][pad]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
callback(null, {padIDs: allPads});
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************/
|
/******************************/
|
||||||
|
|
|
@ -106,29 +106,25 @@ exports.deleteGroup = function(groupID, callback)
|
||||||
db.get("groups", function (err, groups)
|
db.get("groups", function (err, groups)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
|
||||||
if(ERR(err, callback)) return;
|
existingGroups = [];
|
||||||
|
|
||||||
existingGroups = [];
|
if(groups != undefined)
|
||||||
|
{
|
||||||
if(groups != undefined)
|
for(var key in groups['groups'])
|
||||||
{
|
{
|
||||||
for(var key in groups['groups'])
|
if(groupID != groups['groups'][key])
|
||||||
{
|
{
|
||||||
if(groupID != groups['groups'][key])
|
existingGroups.push(groups['groups'][key]);
|
||||||
{
|
}
|
||||||
existingGroups.push(groups['groups'][key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db.set("groups", {groups: existingGroups});
|
db.set("groups", {groups: existingGroups});
|
||||||
});
|
});
|
||||||
|
|
||||||
db.remove("group2sessions:" + groupID);
|
db.remove("group2sessions:" + groupID);
|
||||||
db.remove("group:" + groupID);
|
db.remove("group:" + groupID);
|
||||||
|
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
], function(err)
|
], function(err)
|
||||||
|
@ -169,10 +165,10 @@ exports.createGroup = function(callback)
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
if(responseGroups != undefined)
|
if(responseGroups != undefined)
|
||||||
{
|
{
|
||||||
for(var key in responseGroups['groups'])
|
for(var key in responseGroups['groups'])
|
||||||
{
|
{
|
||||||
existingGroups.push(responseGroups['groups'][key]);
|
existingGroups.push(responseGroups['groups'][key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -351,21 +351,21 @@ Pad.prototype.init = function init(text, callback) {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(text));
|
var firstChangeset = Changeset.makeSplice("\n", 0, 0, exports.cleanText(text));
|
||||||
|
|
||||||
// if this is a non group pad, add this to the defaultGroup
|
// if this is a non group pad, add this to the defaultGroup
|
||||||
if(_this.id.indexOf("$")==-1)
|
if(_this.id.indexOf("$")==-1)
|
||||||
{
|
{
|
||||||
groupID = "g.defaultGroupName";
|
groupID = "g.defaultGroupName";
|
||||||
groupManager.doesGroupExist(groupID, function(err, exists)
|
groupManager.doesGroupExist(groupID, function(err, exists)
|
||||||
{
|
{
|
||||||
if(!exists)
|
if(!exists)
|
||||||
{
|
{
|
||||||
db.set("group:" + groupID, {pads: {}});
|
db.set("group:" + groupID, {pads: {}});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
db.setSub("group:"+groupID, ["pads", _this.id], 1);
|
db.setSub("group:"+groupID, ["pads", _this.id], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_this.appendRevision(firstChangeset, '');
|
_this.appendRevision(firstChangeset, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue