Refactor notification list loading

So that notifications are reloaded (if needed) every time the
notifications dropdown button is clicked
This commit is contained in:
Toby Zerner 2015-08-04 21:22:22 +09:30
parent eee34598f1
commit c74b3434e7
3 changed files with 8 additions and 4 deletions

View File

@ -18,8 +18,6 @@ export default class NotificationList extends Component {
* @type {Boolean}
*/
this.loading = false;
this.load();
}
view() {

View File

@ -12,6 +12,8 @@ export default class NotificationsDropdown extends Component {
* @type {Boolean}
*/
this.showing = false;
this.list = new NotificationList();
}
view() {
@ -28,7 +30,7 @@ export default class NotificationsDropdown extends Component {
<span className="Button-label">{app.trans('core.notifications')}</span>
</a>
<div className="Dropdown-menu Dropdown-menu--right" onclick={this.menuClick.bind(this)}>
{this.showing ? NotificationList.component() : ''}
{this.showing ? this.list.render() : ''}
</div>
</div>
);
@ -39,6 +41,7 @@ export default class NotificationsDropdown extends Component {
m.route(app.route('notifications'));
} else {
this.showing = true;
this.list.load();
}
}

View File

@ -13,9 +13,12 @@ export default class NotificationsPage extends Component {
app.history.push('notifications');
app.drawer.hide();
app.modal.close();
this.list = new NotificationList();
this.list.load();
}
view() {
return <div className="NotificationsPage">{NotificationList.component()}</div>;
return <div className="NotificationsPage">{this.list.render()}</div>;
}
}