From e3d07cb8cc55623d99f157db08ee02bb2f121c23 Mon Sep 17 00:00:00 2001 From: IanM <16573496+imorland@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:43:40 +0100 Subject: [PATCH] feat: make it easier to add content after the first post (#4050) --- .../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 5310cf642..13aa8aeb7 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} */