Change naming, make more general

This commit is contained in:
Wyatt Benno 2019-12-09 09:02:34 +09:00
parent 01855f315c
commit e86af0c965
5 changed files with 17 additions and 20 deletions

View file

@ -39,8 +39,8 @@ const Timeline = {
timelineError () { timelineError () {
return this.$store.state.statuses.error return this.$store.state.statuses.error
}, },
error403 () { errorData () {
return this.$store.state.statuses.error403 return this.$store.state.statuses.errorData
}, },
newStatusCount () { newStatusCount () {
return this.timeline.newStatusCount return this.timeline.newStatusCount

View file

@ -12,21 +12,21 @@
{{ $t('timeline.error_fetching') }} {{ $t('timeline.error_fetching') }}
</div> </div>
<div <div
v-else-if="error403" v-else-if="errorData"
class="loadmore-error alert error" class="loadmore-error alert error"
@click.prevent @click.prevent
> >
{{ $t('timeline.error_403') }} {{ $t('timeline.error_403') }}
</div> </div>
<button <button
v-if="timeline.newStatusCount > 0 && !timelineError && !error403" v-if="timeline.newStatusCount > 0 && !timelineError && !errorData"
class="loadmore-button" class="loadmore-button"
@click.prevent="showNewStatuses" @click.prevent="showNewStatuses"
> >
{{ $t('timeline.show_new') }}{{ newStatusCountStr }} {{ $t('timeline.show_new') }}{{ newStatusCountStr }}
</button> </button>
<div <div
v-if="!timeline.newStatusCount > 0 && !timelineError && !error403" v-if="!timeline.newStatusCount > 0 && !timelineError && !errorData"
class="loadmore-text faint" class="loadmore-text faint"
@click.prevent @click.prevent
> >
@ -74,17 +74,17 @@
{{ $t('timeline.no_more_statuses') }} {{ $t('timeline.no_more_statuses') }}
</div> </div>
<a <a
v-else-if="!timeline.loading && !error403" v-else-if="!timeline.loading && !errorData"
href="#" href="#"
@click.prevent="fetchOlderStatuses()" @click.prevent="fetchOlderStatuses()"
> >
<div class="new-status-notification text-center panel-footer">{{ $t('timeline.load_older') }}</div> <div class="new-status-notification text-center panel-footer">{{ $t('timeline.load_older') }}</div>
</a> </a>
<a <a
v-else-if="error403" v-else-if="errorData"
href="#" href="#"
> >
<div class="new-status-notification text-center panel-footer">{{ error403 }}</div> <div class="new-status-notification text-center panel-footer">{{ errorData }}</div>
</a> </a>
<div <div
v-else v-else

View file

@ -38,7 +38,7 @@ export const defaultState = () => ({
notifications: emptyNotifications(), notifications: emptyNotifications(),
favorites: new Set(), favorites: new Set(),
error: false, error: false,
error403: false, errorData: '',
timelines: { timelines: {
mentions: emptyTl(), mentions: emptyTl(),
public: emptyTl(), public: emptyTl(),
@ -480,8 +480,8 @@ export const mutations = {
setError (state, { value }) { setError (state, { value }) {
state.error = value state.error = value
}, },
set403Error (state, { value }) { setErrorData (state, { value }) {
state.error403 = value state.errorData = value
}, },
setNotificationsLoading (state, { value }) { setNotificationsLoading (state, { value }) {
state.notifications.loading = value state.notifications.loading = value
@ -532,8 +532,8 @@ const statuses = {
setError ({ rootState, commit }, { value }) { setError ({ rootState, commit }, { value }) {
commit('setError', { value }) commit('setError', { value })
}, },
set403Error ({ rootState, commit }, { value }) { setErrorData ({ rootState, commit }, { value }) {
commit('set403Error', { value }) commit('setErrorData', { value })
}, },
setNotificationsLoading ({ rootState, commit }, { value }) { setNotificationsLoading ({ rootState, commit }, { value }) {
commit('setNotificationsLoading', { value }) commit('setNotificationsLoading', { value })

View file

@ -532,10 +532,7 @@ const fetchTimeline = ({
return fetch(url, { headers: authHeaders(credentials) }) return fetch(url, { headers: authHeaders(credentials) })
.then((data) => { .then((data) => {
if (data.ok || data.status === 403) { return data
return data
}
throw new Error('Error fetching timeline', data)
}) })
.then((data) => data.json()) .then((data) => data.json())
.then((data) => { .then((data) => {

View file

@ -6,7 +6,7 @@ const update = ({ store, statuses, timeline, showImmediately, userId }) => {
const ccTimeline = camelCase(timeline) const ccTimeline = camelCase(timeline)
store.dispatch('setError', { value: false }) store.dispatch('setError', { value: false })
store.dispatch('set403Error', { value: false }) store.dispatch('setErrorData', { value: false })
store.dispatch('addNewStatuses', { store.dispatch('addNewStatuses', {
timeline: ccTimeline, timeline: ccTimeline,
@ -46,9 +46,9 @@ const fetchAndUpdate = ({
return apiService.fetchTimeline(args) return apiService.fetchTimeline(args)
.then((statuses) => { .then((statuses) => {
// Change messaging if not public
if (statuses.error) { if (statuses.error) {
store.dispatch('set403Error', { value: statuses.error }) console.log(statuses)
store.dispatch('setErrorData', { value: statuses.error })
return return
} }
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) { if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {