Fix race condition in post preview

The post composer could have been closed in between scheduling and
executing the callback.

Fixes flarum/org#58.
Refs #1881.
This commit is contained in:
Franz Liedke 2020-02-07 12:17:11 +01:00
parent ac14f84a9a
commit 2f3d9995d1
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4

View File

@ -52,6 +52,10 @@ export default class ReplyPlaceholder extends Component {
// body with a preview.
let preview;
const updateInterval = setInterval(() => {
// Since we're polling, the composer may have been closed in the meantime,
// so we bail in that case.
if (!app.composer.component) return;
const content = app.composer.component.content();
if (preview === content) return;