aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaehoon <th.dev91@gmail.com>2019-05-03 07:52:22 -0400
committertaehoon <th.dev91@gmail.com>2019-05-03 07:52:22 -0400
commit6ae3c1cfcf896839f799888e53fc751db952b0f1 (patch)
tree54b6155f0421cb81723f4da154b5e0dd3ff56685
parentb4122c1003cee770721422d8338eb3150bb6bfaf (diff)
autoload older notifications when scrolled to the bottom
-rw-r--r--src/components/mobile_nav/mobile_nav.js5
-rw-r--r--src/components/mobile_nav/mobile_nav.vue2
-rw-r--r--src/components/notifications/notifications.js4
3 files changed, 10 insertions, 1 deletions
diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js
index bc63d2ba..9b341a3b 100644
--- a/src/components/mobile_nav/mobile_nav.js
+++ b/src/components/mobile_nav/mobile_nav.js
@@ -63,6 +63,11 @@ const MobileNav = {
},
markNotificationsAsSeen () {
this.$refs.notifications.markAsSeen()
+ },
+ onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
+ if (this.$store.state.config.autoLoad && scrollTop + clientHeight >= scrollHeight) {
+ this.$refs.notifications.fetchOlderNotifications()
+ }
}
},
watch: {
diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue
index 30b1715f..90707ce7 100644
--- a/src/components/mobile_nav/mobile_nav.vue
+++ b/src/components/mobile_nav/mobile_nav.vue
@@ -28,7 +28,7 @@
<i class="button-icon icon-cancel"/>
</a>
</div>
- <div v-if="currentUser" class="mobile-notifications">
+ <div class="mobile-notifications" @scroll="onScroll">
<Notifications ref="notifications" noHeading="true"/>
</div>
</div>
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js
index e341212e..5b13b98e 100644
--- a/src/components/notifications/notifications.js
+++ b/src/components/notifications/notifications.js
@@ -52,6 +52,10 @@ const Notifications = {
this.$store.dispatch('markNotificationsAsSeen')
},
fetchOlderNotifications () {
+ if (this.loading) {
+ return
+ }
+
const store = this.$store
const credentials = store.state.users.currentUser.credentials
store.commit('setNotificationsLoading', { value: true })