mirror of
https://github.com/flarum/framework.git
synced 2025-02-02 03:17:30 +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 {
|
export default class NotificationList extends Component {
|
||||||
view() {
|
view() {
|
||||||
const state = this.attrs.state;
|
const state = this.attrs.state;
|
||||||
const pages = state.getPages();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="NotificationList">
|
<div className="NotificationList">
|
||||||
|
@ -29,9 +28,18 @@ export default class NotificationList extends Component {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="NotificationList-content">
|
<div className="NotificationList-content">{this.content(state)}</div>
|
||||||
{state.hasItems()
|
</div>
|
||||||
? pages.map((page) => {
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
content(state) {
|
||||||
|
if (state.isLoading()) {
|
||||||
|
return <LoadingIndicator className="LoadingIndicator--block" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.hasItems()) {
|
||||||
|
return state.getPages().map((page) => {
|
||||||
const groups = [];
|
const groups = [];
|
||||||
const discussions = {};
|
const discussions = {};
|
||||||
|
|
||||||
|
@ -81,18 +89,10 @@ export default class NotificationList extends Component {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
: ''}
|
}
|
||||||
{state.isLoading() ? (
|
|
||||||
<LoadingIndicator className="LoadingIndicator--block" />
|
return <div className="NotificationList-empty">{app.translator.trans('core.forum.notifications.empty_text')}</div>;
|
||||||
) : pages.length ? (
|
|
||||||
''
|
|
||||||
) : (
|
|
||||||
<div className="NotificationList-empty">{app.translator.trans('core.forum.notifications.empty_text')}</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oncreate(vnode) {
|
oncreate(vnode) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user