Only show notification icon when there's at least 1 notification. Only show "load more" when there's more 🙄

This commit is contained in:
Son NK 2020-05-23 22:52:35 +02:00
parent 1e03f26cfa
commit 3c6d137bf1
2 changed files with 10 additions and 5 deletions

View File

@ -57,7 +57,8 @@
notifications: [],
page: 0,
loading: true,
canLoadMore: true
canLoadMore: false,
showNotification: false,
},
computed: {
has_non_read_notification: function () {
@ -94,8 +95,8 @@
});
if (res.ok) {
let json = await res.json();
if (json.length == 0) that.canLoadMore = false;
that.notifications = that.notifications.concat(json);
that.canLoadMore = json.more;
that.notifications = that.notifications.concat(json.notifications);
}
}
@ -110,8 +111,11 @@
});
if (res.ok) {
let json = await res.json();
that.notifications = json;
that.notifications = json.notifications;
that.loading = false;
that.canLoadMore = json.more
if (that.notifications.length > 0)
that.showNotification = true;
}
}
})

View File

@ -15,7 +15,8 @@
</div>
{% endif %}
<div id="notification-app" class="dropdown d-none d-md-flex">
<div id="notification-app" class="dropdown d-none d-md-flex" v-if="showNotification">
<a class="nav-link icon" data-toggle="collapse" href="#notifications" style="height: 100%">
<i class="fe fe-bell"></i>
<span v-if="has_non_read_notification" class="nav-unread"></span>