logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe
commit: 7aa1f02e388796942d3f711796497e76b9fcdaac
parent: 0ce747d2c3fb20affb03a0ce102caeb15b84032a
Author: Shpuld Shpuldson <shpuld@gmail.com>
Date:   Thu,  9 Mar 2017 08:06:59 -0500

Merge branch 'feature/timeline-fetch-error' into 'develop'

Use one error variable for all timelines

See merge request !57

Diffstat:

Msrc/components/timeline/timeline.js3+++
Msrc/components/timeline/timeline.vue6+++---
Msrc/modules/statuses.js21+++++++++------------
Msrc/services/timeline_fetcher/timeline_fetcher.service.js13++-----------
4 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js @@ -8,6 +8,9 @@ const Timeline = { 'timelineName', 'title' ], + computed: { + timelineError () { return this.$store.state.statuses.error } + }, components: { Status, StatusOrConversation diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue @@ -4,13 +4,13 @@ <div class="title"> {{title}} </div> - <button @click.prevent="showNewStatuses" class="base06 base02-background loadmore-button" v-if="timeline.newStatusCount > 0 && !timeline.error"> + <button @click.prevent="showNewStatuses" class="base06 base02-background loadmore-button" v-if="timeline.newStatusCount > 0 && !timelineError"> Show new ({{timeline.newStatusCount}}) </button> - <button @click.prevent class="base06 error no-press loadmore-button" v-if="timeline.error"> + <button @click.prevent class="base06 error no-press loadmore-button" v-if="timelineError"> Error fetching updates </button> - <button @click.prevent class="base04 base01-background no-press loadmore-button" v-if="!timeline.newStatusCount > 0 && !timeline.error"> + <button @click.prevent class="base04 base01-background no-press loadmore-button" v-if="!timeline.newStatusCount > 0 && !timelineError"> Up-to-date </button> </div> diff --git a/src/modules/statuses.js b/src/modules/statuses.js @@ -8,6 +8,7 @@ export const defaultState = { maxId: 0, notifications: [], favorites: new Set(), + error: false, timelines: { mentions: { statuses: [], @@ -18,8 +19,7 @@ export const defaultState = { newStatusCount: 0, maxId: 0, minVisibleId: 0, - loading: false, - error: false + loading: false }, public: { statuses: [], @@ -30,8 +30,7 @@ export const defaultState = { newStatusCount: 0, maxId: 0, minVisibleId: 0, - loading: false, - error: false + loading: false }, publicAndExternal: { statuses: [], @@ -42,8 +41,7 @@ export const defaultState = { newStatusCount: 0, maxId: 0, minVisibleId: 0, - loading: false, - error: false + loading: false }, friends: { statuses: [], @@ -54,8 +52,7 @@ export const defaultState = { newStatusCount: 0, maxId: 0, minVisibleId: 0, - loading: false, - error: false + loading: false } } } @@ -298,8 +295,8 @@ export const mutations = { const newStatus = state.allStatusesObject[id] newStatus.nsfw = nsfw }, - setError (state, { timeline, value }) { - state.timelines[timeline].error = value + setError (state, { value }) { + state.error = value }, markNotificationsAsSeen (state, notifications) { each(notifications, (notification) => { @@ -314,8 +311,8 @@ const statuses = { addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false }) { commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser }) }, - setError ({ rootState, commit }, { timeline, value }) { - commit('setError', { timeline, value }) + setError ({ rootState, commit }, { value }) { + commit('setError', { value }) }, deleteStatus ({ rootState, commit }, status) { commit('setDeleted', { status }) diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -5,7 +5,7 @@ import apiService from '../api/api.service.js' const update = ({store, statuses, timeline, showImmediately}) => { const ccTimeline = camelCase(timeline) - setError({store, timeline, value: false}) + store.dispatch('setError', { value: false }) store.dispatch('addNewStatuses', { timeline: ccTimeline, @@ -14,15 +14,6 @@ const update = ({store, statuses, timeline, showImmediately}) => { }) } -const setError = ({store, timeline, value}) => { - const ccTimeline = camelCase(timeline) - - store.dispatch('setError', { - timeline: ccTimeline, - value - }) -} - const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false}) => { const args = { timeline, credentials } const rootState = store.rootState || store.state @@ -36,7 +27,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false return apiService.fetchTimeline(args) .then((statuses) => update({store, statuses, timeline, showImmediately}), - () => setError({store, timeline, value: true})) + () => store.dispatch('setError', { value: true })) } const startFetching = ({ timeline = 'friends', credentials, store }) => {