mirror of
https://github.com/flarum/framework.git
synced 2025-02-09 10:54:01 +08:00
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:
parent
67dd2c21b6
commit
6f4f964ce8
|
@ -4,6 +4,7 @@ import ScrollListener from '../../common/utils/ScrollListener';
|
||||||
import PostLoading from './LoadingPost';
|
import PostLoading from './LoadingPost';
|
||||||
import ReplyPlaceholder from './ReplyPlaceholder';
|
import ReplyPlaceholder from './ReplyPlaceholder';
|
||||||
import Button from '../../common/components/Button';
|
import Button from '../../common/components/Button';
|
||||||
|
import ItemList from '../../common/utils/ItemList';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `PostStream` component displays an infinitely-scrollable wall of posts in
|
* 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
|
// 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.
|
// is not already doing so, then show a 'write a reply' placeholder.
|
||||||
if (viewingEnd && (!app.session.user || this.discussion.canReply())) {
|
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) {
|
onupdate(vnode) {
|
||||||
super.onupdate(vnode);
|
super.onupdate(vnode);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user