Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add misssing hooks to config-hooks-extension. #736

Merged

Conversation

shincurry
Copy link
Contributor

afterLoadDocument and afterUnloadDocument hook functions passed in HocuspocusServer.configure({ ... }) will not be called, these two hooks have not been added to the config-hooks-extension.

this.configuration.extensions.push({
onConfigure: this.configuration.onConfigure,
onListen: this.configuration.onListen,
onUpgrade: this.configuration.onUpgrade,
onConnect: this.configuration.onConnect,
connected: this.configuration.connected,
onAuthenticate: this.configuration.onAuthenticate,
onLoadDocument: this.configuration.onLoadDocument,
beforeHandleMessage: this.configuration.beforeHandleMessage,
beforeBroadcastStateless: this.configuration.beforeBroadcastStateless,
onStateless: this.configuration.onStateless,
onChange: this.configuration.onChange,
onStoreDocument: this.configuration.onStoreDocument,
afterStoreDocument: this.configuration.afterStoreDocument,
onAwarenessUpdate: this.configuration.onAwarenessUpdate,
onRequest: this.configuration.onRequest,
onDisconnect: this.configuration.onDisconnect,
onDestroy: this.configuration.onDestroy,
})

await this.hooks('afterLoadDocument', hookPayload)

hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback: Function | null = null): Promise<any> {
const { extensions } = this.configuration
// create a new `thenable` chain
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve
let chain = Promise.resolve()
extensions
// get me all extensions which have the given hook

@shincurry shincurry changed the title Add misssing hooks to preset configuration extension. Add misssing hooks to config-hooks-extension. Oct 24, 2023
@janthurau janthurau force-pushed the fix-missing-hooks-in-config-extension branch from f9bdb80 to c20eff2 Compare November 12, 2023 10:56
@janthurau janthurau merged commit 0e437bd into ueberdosis:main Nov 12, 2023
3 checks passed
@shincurry shincurry deleted the fix-missing-hooks-in-config-extension branch November 15, 2023 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants