Skip to content

Commit 71c8f2d

Browse files
feat(core): make it easier to add content after the first post
1 parent fdaf097 commit 71c8f2d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

framework/core/js/src/forum/components/PostStream.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,22 @@ export default class PostStream extends Component {
7878
content = <LoadingPost />;
7979
}
8080

81-
return (
81+
const postStreamElement = (
8282
<div className="PostStream-item" {...attrs}>
8383
{content}
8484
</div>
8585
);
86+
87+
if (i === 0 && this.afterFirstPostItems().toArray().length > 0) {
88+
return m.fragment({ ...attrs }, [
89+
postStreamElement,
90+
<div className="PostStream-item PostStream-afterFirstPost" key="afterFirstPost">
91+
{this.afterFirstPostItems().toArray()}
92+
</div>,
93+
]);
94+
}
95+
96+
return postStreamElement;
8697
});
8798

8899
if (!viewingEnd && posts[this.stream.visibleEnd - this.stream.visibleStart - 1]) {
@@ -117,6 +128,15 @@ export default class PostStream extends Component {
117128
);
118129
}
119130

131+
/**
132+
* @returns {ItemList<import('mithril').Children>}
133+
*/
134+
afterFirstPostItems() {
135+
const items = new ItemList();
136+
137+
return items;
138+
}
139+
120140
/**
121141
* @returns {ItemList<import('mithril').Children>}
122142
*/

0 commit comments

Comments
 (0)