mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Pad: Improve readability of appendRevision()
This commit is contained in:
parent
0d52f985bd
commit
2ca740c1db
1 changed files with 15 additions and 18 deletions
|
@ -81,27 +81,24 @@ class Pad {
|
||||||
|
|
||||||
const newRev = ++this.head;
|
const newRev = ++this.head;
|
||||||
|
|
||||||
const newRevData = {};
|
|
||||||
newRevData.changeset = aChangeset;
|
|
||||||
newRevData.meta = {};
|
|
||||||
newRevData.meta.author = authorId;
|
|
||||||
newRevData.meta.timestamp = Date.now();
|
|
||||||
|
|
||||||
// ex. getNumForAuthor
|
// ex. getNumForAuthor
|
||||||
if (authorId !== '') this.pool.putAttrib(['author', authorId]);
|
if (authorId !== '') this.pool.putAttrib(['author', authorId]);
|
||||||
|
|
||||||
if (newRev === this.getKeyRevisionNumber(newRev)) {
|
const p = Promise.all([
|
||||||
newRevData.meta.pool = this.pool;
|
this.db.set(`pad:${this.id}:revs:${newRev}`, {
|
||||||
newRevData.meta.atext = this.atext;
|
changeset: aChangeset,
|
||||||
}
|
meta: {
|
||||||
|
author: authorId,
|
||||||
const p = [
|
timestamp: Date.now(),
|
||||||
this.db.set(`pad:${this.id}:revs:${newRev}`, newRevData),
|
...newRev === this.getKeyRevisionNumber(newRev) ? {
|
||||||
|
pool: this.pool,
|
||||||
|
atext: this.atext,
|
||||||
|
} : {},
|
||||||
|
},
|
||||||
|
}),
|
||||||
this.saveToDatabase(),
|
this.saveToDatabase(),
|
||||||
];
|
authorId && authorManager.addPad(authorId, this.id),
|
||||||
|
]);
|
||||||
// set the author to pad
|
|
||||||
if (authorId) p.push(authorManager.addPad(authorId, this.id));
|
|
||||||
|
|
||||||
let hook = 'padCreate';
|
let hook = 'padCreate';
|
||||||
const context = {
|
const context = {
|
||||||
|
@ -123,7 +120,7 @@ class Pad {
|
||||||
}
|
}
|
||||||
hooks.callAll(hook, context);
|
hooks.callAll(hook, context);
|
||||||
|
|
||||||
await Promise.all(p);
|
await p;
|
||||||
return newRev;
|
return newRev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue