logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe
commit: 1717e700469cb6331e2905c7af0d384cf78a1188
parent: 0bd77149a06bcd7e0a904d0f5c2e2691996ff898
Author: lambda <pleromagit@rogerbraun.net>
Date:   Wed, 30 Jan 2019 17:49:27 +0000

Merge branch 'feat/dont-show-load-more-when-bottomed-out' into 'develop'

fix #292 dont show "load more" when bottomed out

Closes #292

See merge request pleroma/pleroma-fe!496

Diffstat:

Msrc/App.scss6++++++
Msrc/components/notifications/notifications.js14++++++++++++++
Msrc/components/notifications/notifications.vue9+++++++--
Msrc/components/timeline/timeline.js10++++++++--
Msrc/components/timeline/timeline.vue9+++++++--
Msrc/i18n/en.json6++++--
Msrc/i18n/fi.json6++++--
Msrc/modules/statuses.js7+++++++
Msrc/services/notifications_fetcher/notifications_fetcher.service.js1+
Msrc/services/timeline_fetcher/timeline_fetcher.service.js1+
10 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/src/App.scss b/src/App.scss @@ -425,6 +425,12 @@ main-router { border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius; border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius); + + .faint { + color: $fallback--faint; + color: var(--panelFaint, $fallback--faint); + } + a { color: $fallback--link; color: var(--panelLink, $fallback--link) diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js @@ -13,6 +13,11 @@ const Notifications = { notificationsFetcher.startFetching({ store, credentials }) }, + data () { + return { + bottomedOut: false + } + }, computed: { notifications () { return notificationsFromStore(this.$store) @@ -28,6 +33,9 @@ const Notifications = { }, unseenCount () { return this.unseenNotifications.length + }, + loading () { + return this.$store.state.statuses.notifications.loading } }, components: { @@ -49,10 +57,16 @@ const Notifications = { fetchOlderNotifications () { const store = this.$store const credentials = store.state.users.currentUser.credentials + store.commit('setNotificationsLoading', { value: true }) notificationsFetcher.fetchAndUpdate({ store, credentials, older: true + }).then(notifs => { + store.commit('setNotificationsLoading', { value: false }) + if (notifs.length === 0) { + this.bottomedOut = true + } }) } } diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue @@ -18,10 +18,15 @@ </div> </div> <div class="panel-footer"> - <a href="#" v-on:click.prevent='fetchOlderNotifications()' v-if="!notifications.loading"> + <div v-if="bottomedOut" class="new-status-notification text-center panel-footer faint"> + {{$t('notifications.no_more_notifications')}} + </div> + <a v-else-if="!loading" href="#" v-on:click.prevent="fetchOlderNotifications()"> <div class="new-status-notification text-center panel-footer">{{$t('notifications.load_older')}}</div> </a> - <div class="new-status-notification text-center panel-footer" v-else>...</div> + <div v-else class="new-status-notification text-center panel-footer"> + <i class="icon-spin3 animate-spin"/> + </div> </div> </div> </div> diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js @@ -16,7 +16,8 @@ const Timeline = { data () { return { paused: false, - unfocused: false + unfocused: false, + bottomedOut: false } }, computed: { @@ -95,7 +96,12 @@ const Timeline = { showImmediately: true, userId: this.userId, tag: this.tag - }).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false })) + }).then(statuses => { + store.commit('setLoading', { timeline: this.timelineName, value: false }) + if (statuses.length === 0) { + this.bottomedOut = true + } + }) }, 1000, this), scrollLoad (e) { const bodyBRect = document.body.getBoundingClientRect() diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue @@ -20,10 +20,15 @@ </div> </div> <div :class="classes.footer"> - <a href="#" v-on:click.prevent='fetchOlderStatuses()' v-if="!timeline.loading"> + <div v-if="bottomedOut" class="new-status-notification text-center panel-footer faint"> + {{$t('timeline.no_more_statuses')}} + </div> + <a v-else-if="!timeline.loading" href="#" v-on:click.prevent='fetchOlderStatuses()'> <div class="new-status-notification text-center panel-footer">{{$t('timeline.load_older')}}</div> </a> - <div class="new-status-notification text-center panel-footer" v-else>...</div> + <div v-else class="new-status-notification text-center panel-footer"> + <i class="icon-spin3 animate-spin"/> + </div> </div> </div> </template> diff --git a/src/i18n/en.json b/src/i18n/en.json @@ -49,7 +49,8 @@ "load_older": "Load older notifications", "notifications": "Notifications", "read": "Read!", - "repeated_you": "repeated your status" + "repeated_you": "repeated your status", + "no_more_notifications": "No more notifications" }, "post_status": { "new_status": "Post new status", @@ -318,7 +319,8 @@ "no_retweet_hint": "Post is marked as followers-only or direct and cannot be repeated", "repeated": "repeated", "show_new": "Show new", - "up_to_date": "Up-to-date" + "up_to_date": "Up-to-date", + "no_more_statuses": "No more statuses" }, "user_card": { "approve": "Approve", diff --git a/src/i18n/fi.json b/src/i18n/fi.json @@ -26,7 +26,8 @@ "followed_you": "seuraa sinua", "notifications": "Ilmoitukset", "read": "Lue!", - "repeated_you": "toisti viestisi" + "repeated_you": "toisti viestisi", + "no_more_notifications": "Ei enempää ilmoituksia" }, "post_status": { "default": "Tulin juuri saunasta.", @@ -77,7 +78,8 @@ "load_older": "Lataa vanhempia viestejä", "repeated": "toisti", "show_new": "Näytä uudet", - "up_to_date": "Ajantasalla" + "up_to_date": "Ajantasalla", + "no_more_statuses": "Ei enempää viestejä" }, "user_card": { "follow": "Seuraa", diff --git a/src/modules/statuses.js b/src/modules/statuses.js @@ -28,6 +28,7 @@ export const defaultState = { minId: Number.POSITIVE_INFINITY, data: [], idStore: {}, + loading: false, error: false }, favorites: new Set(), @@ -348,6 +349,9 @@ export const mutations = { setError (state, { value }) { state.error = value }, + setNotificationsLoading (state, { value }) { + state.notifications.loading = value + }, setNotificationsError (state, { value }) { state.notifications.error = value }, @@ -376,6 +380,9 @@ const statuses = { setError ({ rootState, commit }, { value }) { commit('setError', { value }) }, + setNotificationsLoading ({ rootState, commit }, { value }) { + commit('setNotificationsLoading', { value }) + }, setNotificationsError ({ rootState, commit }, { value }) { commit('setNotificationsError', { value }) }, diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -24,6 +24,7 @@ const fetchAndUpdate = ({store, credentials, older = false}) => { return apiService.fetchTimeline(args) .then((notifications) => { update({store, notifications, older}) + return notifications }, () => store.dispatch('setNotificationsError', { value: true })) .catch(() => store.dispatch('setNotificationsError', { value: true })) } diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -35,6 +35,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId }) } update({store, statuses, timeline, showImmediately, userId}) + return statuses }, () => store.dispatch('setError', { value: true })) }