mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
Pad: Call padCreate
, padUpdate
hooks asynchronously
This commit is contained in:
parent
2ca740c1db
commit
ff494563d9
2 changed files with 20 additions and 25 deletions
|
@ -75,13 +75,13 @@
|
|||
* The `destinationID` context property is deprecated; use `dstPad.id`
|
||||
instead.
|
||||
* `padCreate`: The `author` context property is deprecated; use the new
|
||||
`authorId` context property instead.
|
||||
`authorId` context property instead. Also, the hook now runs asynchronously.
|
||||
* `padLoad`: Now runs when a temporary Pad object is created during import.
|
||||
Also, it now runs asynchronously.
|
||||
* `padRemove`: The `padID` context property is deprecated; use `pad.id`
|
||||
instead.
|
||||
* `padUpdate`: The `author` context property is deprecated; use the new
|
||||
`authorId` context property instead.
|
||||
`authorId` context property instead. Also, the hook now runs asynchronously.
|
||||
* Returning `true` from a `handleMessageSecurity` hook function is deprecated;
|
||||
return `'permitOnce'` instead.
|
||||
* Changes to the `src/static/js/Changeset.js` library:
|
||||
|
|
|
@ -84,7 +84,8 @@ class Pad {
|
|||
// ex. getNumForAuthor
|
||||
if (authorId !== '') this.pool.putAttrib(['author', authorId]);
|
||||
|
||||
const p = Promise.all([
|
||||
const hook = this.head === 0 ? 'padCreate' : 'padUpdate';
|
||||
await Promise.all([
|
||||
this.db.set(`pad:${this.id}:revs:${newRev}`, {
|
||||
changeset: aChangeset,
|
||||
meta: {
|
||||
|
@ -98,29 +99,23 @@ class Pad {
|
|||
}),
|
||||
this.saveToDatabase(),
|
||||
authorId && authorManager.addPad(authorId, this.id),
|
||||
hooks.aCallAll(hook, {
|
||||
pad: this,
|
||||
authorId,
|
||||
get author() {
|
||||
warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
|
||||
return this.authorId;
|
||||
},
|
||||
set author(authorId) {
|
||||
warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
|
||||
this.authorId = authorId;
|
||||
},
|
||||
...this.head === 0 ? {} : {
|
||||
revs: newRev,
|
||||
changeset: aChangeset,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
let hook = 'padCreate';
|
||||
const context = {
|
||||
pad: this,
|
||||
authorId,
|
||||
get author() {
|
||||
warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
|
||||
return this.authorId;
|
||||
},
|
||||
set author(authorId) {
|
||||
warnDeprecated(`${hook} hook author context is deprecated; use authorId instead`);
|
||||
this.authorId = authorId;
|
||||
},
|
||||
};
|
||||
if (this.head !== 0) {
|
||||
hook = 'padUpdate';
|
||||
context.revs = newRev;
|
||||
context.changeset = aChangeset;
|
||||
}
|
||||
hooks.callAll(hook, context);
|
||||
|
||||
await p;
|
||||
return newRev;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue