Merge branch 'feature/timeline-fetch-error' into 'develop'
Use one error variable for all timelines See merge request !57
This commit is contained in:
commit
7aa1f02e38
4 changed files with 17 additions and 26 deletions
|
@ -8,6 +8,9 @@ const Timeline = {
|
|||
'timelineName',
|
||||
'title'
|
||||
],
|
||||
computed: {
|
||||
timelineError () { return this.$store.state.statuses.error }
|
||||
},
|
||||
components: {
|
||||
Status,
|
||||
StatusOrConversation
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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 }) => {
|
||||
|
|
Loading…
Reference in a new issue