mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 14:14:59 +08:00
PERF: Cache emojified post content
This commit is contained in:
parent
cb358a9084
commit
637e3abfc9
|
@ -5,8 +5,15 @@ import app from 'flarum/app';
|
|||
import Post from 'flarum/models/Post';
|
||||
|
||||
app.initializers.add('emoji', () => {
|
||||
override(Post.prototype, 'contentHtml', original => {
|
||||
return twemoji.parse(original());
|
||||
override(Post.prototype, 'contentHtml', function(original) {
|
||||
const contentHtml = original();
|
||||
|
||||
if (this.oldContentHtml !== contentHtml) {
|
||||
this.emojifiedContentHtml = twemoji.parse(contentHtml);
|
||||
this.oldContentHtml = contentHtml;
|
||||
}
|
||||
|
||||
return this.emojifiedContentHtml;
|
||||
});
|
||||
|
||||
override(s9e.TextFormatter, 'preview', (original, text, element) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user