mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 16:36:15 -04:00
chat: Move message copy to padCopy
hook
This commit is contained in:
parent
01f1a8b75e
commit
bd621043ff
3 changed files with 14 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
||||||
"eejsBlock_stickyContainer": "ep_etherpad-lite/node/chat",
|
"eejsBlock_stickyContainer": "ep_etherpad-lite/node/chat",
|
||||||
"handleMessage": "ep_etherpad-lite/node/chat",
|
"handleMessage": "ep_etherpad-lite/node/chat",
|
||||||
"padCheck": "ep_etherpad-lite/node/chat",
|
"padCheck": "ep_etherpad-lite/node/chat",
|
||||||
|
"padCopy": "ep_etherpad-lite/node/chat",
|
||||||
"padLoad": "ep_etherpad-lite/node/chat",
|
"padLoad": "ep_etherpad-lite/node/chat",
|
||||||
"socketio": "ep_etherpad-lite/node/chat"
|
"socketio": "ep_etherpad-lite/node/chat"
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,6 +156,19 @@ exports.padCheck = async (hookName, {pad}) => {
|
||||||
for (const p of chats.batch(100).buffer(99)) await p;
|
for (const p of chats.batch(100).buffer(99)) await p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.padCopy = async (hookName, {srcPad, dstPad}) => {
|
||||||
|
const {chatHead = -1} = srcPad;
|
||||||
|
dstPad.chatHead = chatHead;
|
||||||
|
const copyChat = async (i) => {
|
||||||
|
const val = await srcPad.db.get(`pad:${srcPad.id}:chat:${i}`);
|
||||||
|
await dstPad.db.set(`pad:${dstPad.id}:chat:${i}`, val);
|
||||||
|
};
|
||||||
|
const ops = (function* () {
|
||||||
|
for (let i = 0; i <= chatHead; ++i) yield copyChat(i);
|
||||||
|
})();
|
||||||
|
for (const op of new Stream(ops).batch(100).buffer(99)) await op;
|
||||||
|
};
|
||||||
|
|
||||||
exports.padLoad = async (hookName, {pad}) => {
|
exports.padLoad = async (hookName, {pad}) => {
|
||||||
if (!('chatHead' in pad)) pad.chatHead = -1;
|
if (!('chatHead' in pad)) pad.chatHead = -1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -372,7 +372,6 @@ class Pad {
|
||||||
const promises = (function* () {
|
const promises = (function* () {
|
||||||
yield copyRecord('');
|
yield copyRecord('');
|
||||||
yield* Stream.range(0, this.head + 1).map((i) => copyRecord(`:revs:${i}`));
|
yield* Stream.range(0, this.head + 1).map((i) => copyRecord(`:revs:${i}`));
|
||||||
yield* Stream.range(0, this.chatHead + 1).map((i) => copyRecord(`:chat:${i}`));
|
|
||||||
yield this.copyAuthorInfoToDestinationPad(destinationID);
|
yield this.copyAuthorInfoToDestinationPad(destinationID);
|
||||||
if (destGroupID) yield db.setSub(`group:${destGroupID}`, ['pads', destinationID], 1);
|
if (destGroupID) yield db.setSub(`group:${destGroupID}`, ['pads', destinationID], 1);
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue