mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 23:29:57 +08:00
Refactor notification list loading
So that notifications are reloaded (if needed) every time the notifications dropdown button is clicked
This commit is contained in:
@ -18,8 +18,6 @@ export default class NotificationList extends Component {
|
|||||||
* @type {Boolean}
|
* @type {Boolean}
|
||||||
*/
|
*/
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
this.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
|
@ -12,6 +12,8 @@ export default class NotificationsDropdown extends Component {
|
|||||||
* @type {Boolean}
|
* @type {Boolean}
|
||||||
*/
|
*/
|
||||||
this.showing = false;
|
this.showing = false;
|
||||||
|
|
||||||
|
this.list = new NotificationList();
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
@ -28,7 +30,7 @@ export default class NotificationsDropdown extends Component {
|
|||||||
<span className="Button-label">{app.trans('core.notifications')}</span>
|
<span className="Button-label">{app.trans('core.notifications')}</span>
|
||||||
</a>
|
</a>
|
||||||
<div className="Dropdown-menu Dropdown-menu--right" onclick={this.menuClick.bind(this)}>
|
<div className="Dropdown-menu Dropdown-menu--right" onclick={this.menuClick.bind(this)}>
|
||||||
{this.showing ? NotificationList.component() : ''}
|
{this.showing ? this.list.render() : ''}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -39,6 +41,7 @@ export default class NotificationsDropdown extends Component {
|
|||||||
m.route(app.route('notifications'));
|
m.route(app.route('notifications'));
|
||||||
} else {
|
} else {
|
||||||
this.showing = true;
|
this.showing = true;
|
||||||
|
this.list.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,12 @@ export default class NotificationsPage extends Component {
|
|||||||
app.history.push('notifications');
|
app.history.push('notifications');
|
||||||
app.drawer.hide();
|
app.drawer.hide();
|
||||||
app.modal.close();
|
app.modal.close();
|
||||||
|
|
||||||
|
this.list = new NotificationList();
|
||||||
|
this.list.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
return <div className="NotificationsPage">{NotificationList.component()}</div>;
|
return <div className="NotificationsPage">{this.list.render()}</div>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user