Skip to content

Commit

Permalink
feat: allow push additional items to the end of the poststream (#3691)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
imorland and davwheat authored Nov 25, 2022
1 parent 67dd2c2 commit 6f4f964
Showing 1 changed file with 15 additions and 0 deletions.
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() {
const items = new ItemList();

return items;
}

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

Expand Down

0 comments on commit 6f4f964

Please # to comment.