mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Merge pull request #2174 from ether/fix/copy-pad-update-lists
Fix #2136: update cache and group list when copying pads
This commit is contained in:
commit
9d1eca42b3
1 changed files with 29 additions and 19 deletions
|
@ -412,6 +412,7 @@ Pad.prototype.init = function init(text, callback) {
|
|||
Pad.prototype.copy = function copy(destinationID, force, callback) {
|
||||
var sourceID = this.id;
|
||||
var _this = this;
|
||||
var destGroupID;
|
||||
|
||||
// make force optional
|
||||
if (typeof force == "function") {
|
||||
|
@ -436,7 +437,8 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
|||
{
|
||||
if (destinationID.indexOf("$") != -1)
|
||||
{
|
||||
groupManager.doesGroupExist(destinationID.split("$")[0], function (err, exists)
|
||||
destGroupID = destinationID.split("$")[0]
|
||||
groupManager.doesGroupExist(destGroupID, function (err, exists)
|
||||
{
|
||||
if(ERR(err, callback)) return;
|
||||
|
||||
|
@ -493,6 +495,7 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
|||
db.get("pad:"+sourceID, function(err, pad) {
|
||||
db.set("pad:"+destinationID, pad);
|
||||
});
|
||||
|
||||
callback();
|
||||
},
|
||||
//copy all relations
|
||||
|
@ -547,6 +550,13 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
|||
// parallel
|
||||
], callback);
|
||||
},
|
||||
function(callback) {
|
||||
// Group pad? Add it to the group's list
|
||||
if(destGroupID) db.setSub("group:" + destGroupID, ["pads", destinationID], 1);
|
||||
|
||||
// Initialize the new pad (will update the listAllPads cache)
|
||||
padManager.getPad(destinationID, null, callback)
|
||||
}
|
||||
// series
|
||||
], function(err)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue