Change 403 messaging
This commit is contained in:
parent
7b1d5a4f5c
commit
13fc2612ae
|
@ -36,7 +36,12 @@ const Timeline = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
timelineError () { return this.$store.state.statuses.error },
|
timelineError () {
|
||||||
|
return this.$store.state.statuses.error
|
||||||
|
},
|
||||||
|
error403 () {
|
||||||
|
return this.$store.state.statuses.error403
|
||||||
|
},
|
||||||
newStatusCount () {
|
newStatusCount () {
|
||||||
return this.timeline.newStatusCount
|
return this.timeline.newStatusCount
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,15 +11,22 @@
|
||||||
>
|
>
|
||||||
{{ $t('timeline.error_fetching') }}
|
{{ $t('timeline.error_fetching') }}
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-else-if="error403"
|
||||||
|
class="loadmore-error alert error"
|
||||||
|
@click.prevent
|
||||||
|
>
|
||||||
|
{{ $t('timeline.error_403') }}
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
v-if="timeline.newStatusCount > 0 && !timelineError"
|
v-if="timeline.newStatusCount > 0 && !timelineError && !error403"
|
||||||
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"
|
v-if="!timeline.newStatusCount > 0 && !timelineError && !error403"
|
||||||
class="loadmore-text faint"
|
class="loadmore-text faint"
|
||||||
@click.prevent
|
@click.prevent
|
||||||
>
|
>
|
||||||
|
@ -67,12 +74,18 @@
|
||||||
{{ $t('timeline.no_more_statuses') }}
|
{{ $t('timeline.no_more_statuses') }}
|
||||||
</div>
|
</div>
|
||||||
<a
|
<a
|
||||||
v-else-if="!timeline.loading"
|
v-else-if="!timeline.loading && !error403"
|
||||||
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
|
||||||
|
v-else-if="error403"
|
||||||
|
href="#"
|
||||||
|
>
|
||||||
|
<div class="new-status-notification text-center panel-footer">{{ $t('timeline.error_403_message') }}</div>
|
||||||
|
</a>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
class="new-status-notification text-center panel-footer"
|
class="new-status-notification text-center panel-footer"
|
||||||
|
|
|
@ -535,6 +535,8 @@
|
||||||
"collapse": "Collapse",
|
"collapse": "Collapse",
|
||||||
"conversation": "Conversation",
|
"conversation": "Conversation",
|
||||||
"error_fetching": "Error fetching updates",
|
"error_fetching": "Error fetching updates",
|
||||||
|
"error_403": "This timeline is not public.",
|
||||||
|
"error_403_message": "Please sign in.",
|
||||||
"load_older": "Load older statuses",
|
"load_older": "Load older statuses",
|
||||||
"no_retweet_hint": "Post is marked as followers-only or direct and cannot be repeated",
|
"no_retweet_hint": "Post is marked as followers-only or direct and cannot be repeated",
|
||||||
"repeated": "repeated",
|
"repeated": "repeated",
|
||||||
|
|
|
@ -38,6 +38,7 @@ export const defaultState = () => ({
|
||||||
notifications: emptyNotifications(),
|
notifications: emptyNotifications(),
|
||||||
favorites: new Set(),
|
favorites: new Set(),
|
||||||
error: false,
|
error: false,
|
||||||
|
error403: false,
|
||||||
timelines: {
|
timelines: {
|
||||||
mentions: emptyTl(),
|
mentions: emptyTl(),
|
||||||
public: emptyTl(),
|
public: emptyTl(),
|
||||||
|
@ -479,6 +480,9 @@ export const mutations = {
|
||||||
setError (state, { value }) {
|
setError (state, { value }) {
|
||||||
state.error = value
|
state.error = value
|
||||||
},
|
},
|
||||||
|
set403Error (state, { value }) {
|
||||||
|
state.error403 = value
|
||||||
|
},
|
||||||
setNotificationsLoading (state, { value }) {
|
setNotificationsLoading (state, { value }) {
|
||||||
state.notifications.loading = value
|
state.notifications.loading = value
|
||||||
},
|
},
|
||||||
|
@ -528,6 +532,9 @@ const statuses = {
|
||||||
setError ({ rootState, commit }, { value }) {
|
setError ({ rootState, commit }, { value }) {
|
||||||
commit('setError', { value })
|
commit('setError', { value })
|
||||||
},
|
},
|
||||||
|
set403Error ({ rootState, commit }, { value }) {
|
||||||
|
commit('set403Error', { value })
|
||||||
|
},
|
||||||
setNotificationsLoading ({ rootState, commit }, { value }) {
|
setNotificationsLoading ({ rootState, commit }, { value }) {
|
||||||
commit('setNotificationsLoading', { value })
|
commit('setNotificationsLoading', { value })
|
||||||
},
|
},
|
||||||
|
|
|
@ -532,13 +532,19 @@ const fetchTimeline = ({
|
||||||
|
|
||||||
return fetch(url, { headers: authHeaders(credentials) })
|
return fetch(url, { headers: authHeaders(credentials) })
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.ok) {
|
if (data.ok || data.status === 403) {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
throw new Error('Error fetching timeline', data)
|
throw new Error('Error fetching timeline', data)
|
||||||
})
|
})
|
||||||
.then((data) => data.json())
|
.then((data) => data.json())
|
||||||
.then((data) => data.map(isNotifications ? parseNotification : parseStatus))
|
.then((data) => {
|
||||||
|
if (!data.error) {
|
||||||
|
return data.map(isNotifications ? parseNotification : parseStatus)
|
||||||
|
} else {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchPinnedStatuses = ({ id, credentials }) => {
|
const fetchPinnedStatuses = ({ id, credentials }) => {
|
||||||
|
|
|
@ -6,6 +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('addNewStatuses', {
|
store.dispatch('addNewStatuses', {
|
||||||
timeline: ccTimeline,
|
timeline: ccTimeline,
|
||||||
|
@ -45,6 +46,11 @@ const fetchAndUpdate = ({
|
||||||
|
|
||||||
return apiService.fetchTimeline(args)
|
return apiService.fetchTimeline(args)
|
||||||
.then((statuses) => {
|
.then((statuses) => {
|
||||||
|
// Change messaging if not public
|
||||||
|
if (statuses.error) {
|
||||||
|
store.dispatch('set403Error', { value: true })
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
|
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
|
||||||
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue