Skip to content

feat: make it easier to add content after the first post #4186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 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,22 @@ export default class PostStream extends Component {
content = <LoadingPost />;
}

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

if (post && post.id() === this.discussion.data.relationships.firstPost?.data.id && this.afterFirstPostItems().toArray().length > 0) {
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 +128,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
Loading