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

* feat: allow push additional items to the end of the poststream

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

Co-authored-by: David Wheatley <hi@davwheat.dev>

* chore: prettier

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

Co-authored-by: David Wheatley <hi@davwheat.dev>

Co-authored-by: David Wheatley <hi@davwheat.dev>
This commit is contained in:
IanM 2022-11-25 10:59:23 +00:00 committed by GitHub
parent 67dd2c21b6
commit 6f4f964ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -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())) {
@ -111,6 +117,15 @@ export default class PostStream extends Component {
);
}
/**
* @returns {ItemList<import('mithril').Children>}
*/
endItems() {
const items = new ItemList();
return items;
}
onupdate(vnode) {
super.onupdate(vnode);