forked from AkkomaGang/akkoma-fe
Merge branch 'feature/timeline-fetch-error' into 'develop'
Visual feedback on failure to fetch new statuses See merge request !47
This commit is contained in:
commit
d954db0221
3 changed files with 33 additions and 6 deletions
|
@ -4,10 +4,13 @@
|
|||
<div class="title">
|
||||
{{title}}
|
||||
</div>
|
||||
<button @click.prevent="showNewStatuses" class="base06 base02-background loadmore-button" v-if="timeline.newStatusCount > 0">
|
||||
<button @click.prevent="showNewStatuses" class="base06 base02-background loadmore-button" v-if="timeline.newStatusCount > 0 && !timeline.error">
|
||||
Show new ({{timeline.newStatusCount}})
|
||||
</button>
|
||||
<button @click.prevent class="base04 base01-background no-press loadmore-button" v-if="!timeline.newStatusCount > 0">
|
||||
<button @click.prevent class="base06 error no-press loadmore-button" v-if="timeline.error">
|
||||
Error fetching updates
|
||||
</button>
|
||||
<button @click.prevent class="base04 base01-background no-press loadmore-button" v-if="!timeline.newStatusCount > 0 && !timeline.error">
|
||||
Up-to-date
|
||||
</button>
|
||||
</div>
|
||||
|
@ -43,6 +46,9 @@
|
|||
padding: 0.1em 0.3em 0.25em 0.3em;
|
||||
min-width: 6em;
|
||||
}
|
||||
.error {
|
||||
background-color: rgba(255, 48, 16, 0.65);
|
||||
}
|
||||
.no-press {
|
||||
opacity: 0.8;
|
||||
cursor: default;
|
||||
|
|
|
@ -15,7 +15,8 @@ export const defaultState = {
|
|||
newStatusCount: 0,
|
||||
maxId: 0,
|
||||
minVisibleId: 0,
|
||||
loading: false
|
||||
loading: false,
|
||||
error: false
|
||||
},
|
||||
public: {
|
||||
statuses: [],
|
||||
|
@ -24,7 +25,8 @@ export const defaultState = {
|
|||
newStatusCount: 0,
|
||||
maxId: 0,
|
||||
minVisibleId: 0,
|
||||
loading: false
|
||||
loading: false,
|
||||
error: false
|
||||
},
|
||||
publicAndExternal: {
|
||||
statuses: [],
|
||||
|
@ -33,7 +35,8 @@ export const defaultState = {
|
|||
newStatusCount: 0,
|
||||
maxId: 0,
|
||||
minVisibleId: 0,
|
||||
loading: false
|
||||
loading: false,
|
||||
error: false
|
||||
},
|
||||
friends: {
|
||||
statuses: [],
|
||||
|
@ -42,7 +45,8 @@ export const defaultState = {
|
|||
newStatusCount: 0,
|
||||
maxId: 0,
|
||||
minVisibleId: 0,
|
||||
loading: false
|
||||
loading: false,
|
||||
error: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,6 +284,9 @@ export const mutations = {
|
|||
const newStatus = find(state.allStatuses, { id })
|
||||
newStatus.nsfw = nsfw
|
||||
},
|
||||
setError (state, { timeline, value }) {
|
||||
state.timelines[timeline].error = value
|
||||
},
|
||||
markNotificationsAsSeen (state, notifications) {
|
||||
each(notifications, (notification) => {
|
||||
notification.seen = true
|
||||
|
@ -293,6 +300,9 @@ 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 })
|
||||
},
|
||||
deleteStatus ({ rootState, commit }, status) {
|
||||
commit('setDeleted', { status })
|
||||
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
|
||||
|
|
|
@ -12,6 +12,15 @@ 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
|
||||
|
@ -25,6 +34,8 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
|
|||
|
||||
return apiService.fetchTimeline(args)
|
||||
.then((statuses) => update({store, statuses, timeline, showImmediately}))
|
||||
.then(() => setError({store, timeline, value: false}))
|
||||
.catch(() => setError({store, timeline, value: true}))
|
||||
}
|
||||
|
||||
const startFetching = ({ timeline = 'friends', credentials, store }) => {
|
||||
|
|
Loading…
Reference in a new issue