commit: b47820905c4a5b44ae0c297e3d9c5484ca202272
parent: b4122c1003cee770721422d8338eb3150bb6bfaf
Author: Shpuld Shpludson <shp@cock.li>
Date:   Fri,  3 May 2019 14:47:54 +0000
Merge branch '516-autoload' into 'develop'
Autoload older notifications when scrolled to the bottom
Closes #516
See merge request pleroma/pleroma-fe!780
Diffstat:
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git 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
@@ -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
@@ -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 })