FIX: don't refresh notifications in a tight loop

This commit is contained in:
Sam 2017-08-28 16:52:00 -04:00
parent 9f0f086b3e
commit 41e7bdff38
1 changed files with 3 additions and 2 deletions

View File

@ -7,7 +7,7 @@ export default createWidget('user-notifications', {
buildKey: () => 'user-notifications', buildKey: () => 'user-notifications',
defaultState() { defaultState() {
return { notifications: [], loading: false }; return { notifications: [], loading: false, loaded: false };
}, },
notificationsChanged() { notificationsChanged() {
@ -49,12 +49,13 @@ export default createWidget('user-notifications', {
state.notifications = []; state.notifications = [];
}).finally(() => { }).finally(() => {
state.loading = false; state.loading = false;
state.loaded = true;
this.scheduleRerender(); this.scheduleRerender();
}); });
}, },
html(attrs, state) { html(attrs, state) {
if (!state.notifications.length) { if (!state.loaded) {
this.refreshNotifications(state); this.refreshNotifications(state);
} }