Refactor composer live previews for better performance

This commit is contained in:
Toby Zerner
2015-07-28 16:06:25 +09:30
parent d445b49d7a
commit 40112ae553
5 changed files with 54 additions and 68 deletions

View File

@ -31,27 +31,6 @@ export default class EditPostComposer extends ComposerBody {
props.post.editedContent = props.originalContent;
}
config(isInitialized, context) {
super.config(isInitialized, context);
if (isInitialized) return;
// Every 50ms, if the content has changed, then update the post's
// editedContent property and redraw. This will cause the preview in the
// post's component to update.
const updateInterval = setInterval(() => {
const post = this.props.post;
const content = this.content();
if (content === post.editedContent) return;
post.editedContent = content;
m.redraw();
}, 50);
context.onunload = () => clearInterval(updateInterval);
}
headerItems() {
const items = super.headerItems();
const post = this.props.post;