Skip to content

Commit

Permalink
[1.x] [extensibility] refactor(core, flags): improve & use extensibil…
Browse files Browse the repository at this point in the history
…ity of `CommentPost` & `Post` (#4047)

* refactor(core): improve extensibility of `CommentPost`

* refactor(core): rename method to more appropriate name

* refactor(core): further improve extensibility of `CommentPost`

* refactor(core): improve extensibility of `Post`

* refactor(flags): use new extensibility for flagged posts
  • Loading branch information
DavideIadeluca authored Oct 2, 2024
1 parent 6013bc0 commit 46ac164
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions js/src/forum/addFlagsToPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,25 @@ export default function () {
return items;
};

extend(Post.prototype, 'content', function (vdom) {
extend(Post.prototype, 'viewItems', function (items) {
const post = this.attrs.post;
const flags = post.flags();

if (!flags.length) return;

if (post.isHidden()) this.revealContent = true;

vdom.unshift(
items.add(
'flagged',
<div className="Post-flagged">
<div className="Post-flagged-flags">
{flags.map((flag) => (
<div className="Post-flagged-flag">{this.flagReason(flag)}</div>
))}
</div>
<div className="Post-flagged-actions">{this.flagActionItems().toArray()}</div>
</div>
</div>,
110
);
});

Expand Down

0 comments on commit 46ac164

Please sign in to comment.