1
0
mirror of https://github.com/flarum/core.git synced 2025-06-26 20:54:56 +02:00

SubtreeRetainer: fix onbeforeupdate needsRebuild (#2365)

This commit is contained in:
Wadim Kalmykov
2020-10-06 22:52:05 +07:00
committed by GitHub
parent 441ccec8e7
commit 63692f12c5

View File

@ -28,6 +28,9 @@ export default class SubtreeRetainer {
constructor(...callbacks) {
this.callbacks = callbacks;
this.data = {};
// Build the initial data, so it is available when calling
// needsRebuild from the onbeforeupdate hook.
this.needsRebuild();
}
/**
@ -60,6 +63,8 @@ export default class SubtreeRetainer {
*/
check(...callbacks) {
this.callbacks = this.callbacks.concat(callbacks);
// Update the data cache when new checks are added.
this.needsRebuild();
}
/**