Merge branch 'akkoma-support-part-2' into 'develop'

better error handling

See merge request pleroma/pleroma-fe!2193
This commit is contained in:
HJ 2025-06-29 12:24:44 +00:00
commit d72438f0a7
2 changed files with 8 additions and 11 deletions

View file

@ -759,7 +759,7 @@ const fetchTimeline = ({
if (replyVisibility !== 'all') {
params.push(['reply_visibility', replyVisibility])
}
if (includeTypes.length > 0) {
if (includeTypes.size > 0) {
includeTypes.forEach(type => {
params.push(['include_types[]', type])
})

View file

@ -34,10 +34,6 @@ const fetchAndUpdate = ({ store, credentials, older = false, since }) => {
mastoApiNotificationTypes.add('pleroma:chat_mention')
}
if (!rootState.instance.statusNotificationTypeAvailable) {
mastoApiNotificationTypes.delete('status')
}
args.includeTypes = mastoApiNotificationTypes
args.withMuted = !hideMutedPosts
@ -81,12 +77,13 @@ const fetchNotifications = ({ store, args, older }) => {
return apiService.fetchTimeline(args)
.then((response) => {
if (response.errors) {
if (response.status === 400 && mastoApiNotificationTypes.has('status')) {
store.dispatch('setInstanceOption', {
name: 'statusNotificationTypeAvailable',
value: false
})
mastoApiNotificationTypes.delete('status')
if (response.status === 400 && response.statusText.includes('Invalid value for enum')) {
response
.statusText
.matchAll(/(\w+) - Invalid value for enum./g)
.toArray()
.map(x => x[1])
.forEach(x => mastoApiNotificationTypes.delete(x))
return fetchNotifications({ store, args, older })
} else {
throw new Error(`${response.status} ${response.statusText}`)