From f3643a13af76551e928cf55f2605e6fc67d6e0aa Mon Sep 17 00:00:00 2001 From: IanM Date: Mon, 30 Sep 2024 11:25:11 +0100 Subject: [PATCH] feat: make it easier to add content after the first post --- .../js/src/forum/components/PostStream.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/framework/core/js/src/forum/components/PostStream.js b/framework/core/js/src/forum/components/PostStream.js index 5310cf6428..13aa8aeb7f 100644 --- a/framework/core/js/src/forum/components/PostStream.js +++ b/framework/core/js/src/forum/components/PostStream.js @@ -78,11 +78,24 @@ export default class PostStream extends Component { content = ; } - return ( + const postStreamElement = (
{content}
); + + // If we're on the first post, call the afterFirstPostItems method and add any additional elements. + if (i === 0 && this.afterFirstPostItems().toArray().length > 0) { + // Using m.fragment to return multiple elements without an enclosing container + return m.fragment({ ...attrs }, [ + postStreamElement, +
+ {this.afterFirstPostItems().toArray()} +
, + ]); + } + + return postStreamElement; }); if (!viewingEnd && posts[this.stream.visibleEnd - this.stream.visibleStart - 1]) { @@ -117,6 +130,15 @@ export default class PostStream extends Component { ); } + /** + * @returns {ItemList} + */ + afterFirstPostItems() { + const items = new ItemList(); + + return items; + } + /** * @returns {ItemList} */