Skip to content
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

[1.x] [extensibility] feat: make it easier to add content after the first post #4050

Merged
merged 1 commit into from
Sep 30, 2024
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
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
Loading