Skip to content

Commit

Permalink
feat: make it easier to add content after the first post
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Sep 30, 2024
1 parent 9bc8c7d commit f3643a1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion framework/core/js/src/forum/components/PostStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,24 @@ export default class PostStream extends Component {
content = <PostLoading />;
}

return (
const postStreamElement = (
<div className="PostStream-item" {...attrs}>
{content}
</div>
);

// 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,
<div className="PostStream-item PostStream-afterFirstPost" key="afterFirstPost">
{this.afterFirstPostItems().toArray()}
</div>,
]);
}

return postStreamElement;
});

if (!viewingEnd && posts[this.stream.visibleEnd - this.stream.visibleStart - 1]) {
Expand Down Expand Up @@ -117,6 +130,15 @@ export default class PostStream extends Component {
);
}

/**
* @returns {ItemList<import('mithril').Children>}
*/
afterFirstPostItems() {
const items = new ItemList();

return items;
}

/**
* @returns {ItemList<import('mithril').Children>}
*/
Expand Down

0 comments on commit f3643a1

Please sign in to comment.