mirror of
https://github.com/flarum/framework.git
synced 2025-02-02 01:11:25 +08:00
NotificationListState separate content method
This fixes an error where an empty notification list wouldn't show the "empty" text. It also simplifies flow of logic and breaks the component up a bit for readability.
This commit is contained in:
parent
dd3c203827
commit
8ffeac4315
|
@ -12,7 +12,6 @@ import Discussion from '../../common/models/Discussion';
|
|||
export default class NotificationList extends Component {
|
||||
view() {
|
||||
const state = this.attrs.state;
|
||||
const pages = state.getPages();
|
||||
|
||||
return (
|
||||
<div className="NotificationList">
|
||||
|
@ -29,9 +28,18 @@ export default class NotificationList extends Component {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="NotificationList-content">
|
||||
{state.hasItems()
|
||||
? pages.map((page) => {
|
||||
<div className="NotificationList-content">{this.content(state)}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
content(state) {
|
||||
if (state.isLoading()) {
|
||||
return <LoadingIndicator className="LoadingIndicator--block" />;
|
||||
}
|
||||
|
||||
if (state.hasItems()) {
|
||||
return state.getPages().map((page) => {
|
||||
const groups = [];
|
||||
const discussions = {};
|
||||
|
||||
|
@ -81,18 +89,10 @@ export default class NotificationList extends Component {
|
|||
</div>
|
||||
);
|
||||
});
|
||||
})
|
||||
: ''}
|
||||
{state.isLoading() ? (
|
||||
<LoadingIndicator className="LoadingIndicator--block" />
|
||||
) : pages.length ? (
|
||||
''
|
||||
) : (
|
||||
<div className="NotificationList-empty">{app.translator.trans('core.forum.notifications.empty_text')}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return <div className="NotificationList-empty">{app.translator.trans('core.forum.notifications.empty_text')}</div>;
|
||||
}
|
||||
|
||||
oncreate(vnode) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user