Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: allow push additional items to the end of the poststream #3691

Merged
merged 4 commits into from
Nov 25, 2022
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
15 changes: 15 additions & 0 deletions framework/core/js/src/forum/components/PostStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ScrollListener from '../../common/utils/ScrollListener';
import PostLoading from './LoadingPost';
import ReplyPlaceholder from './ReplyPlaceholder';
import Button from '../../common/components/Button';
import ItemList from '../../common/utils/ItemList';

/**
* The `PostStream` component displays an infinitely-scrollable wall of posts in
Expand Down Expand Up @@ -94,6 +95,11 @@ export default class PostStream extends Component {
);
}

// Allow extensions to add items to the end of the post stream.
if (viewingEnd) {
items.push(...this.endItems().toArray());
}

// If we're viewing the end of the discussion, the user can reply, and
// is not already doing so, then show a 'write a reply' placeholder.
if (viewingEnd && (!app.session.user || this.discussion.canReply())) {
Expand All @@ -111,6 +117,15 @@ export default class PostStream extends Component {
);
}

/**
* @returns {ItemList<import('mithril').Children>}
*/
endItems() {
imorland marked this conversation as resolved.
Show resolved Hide resolved
const items = new ItemList();

return items;
}

onupdate(vnode) {
super.onupdate(vnode);

Expand Down