From e66b1edcf4d09b730b6cd705862db633b793825f Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 29 Jun 2025 15:24:04 +0300 Subject: [PATCH] better error handling --- src/services/api/api.service.js | 2 +- .../notifications_fetcher.service.js | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 6de94278e..5022e330d 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -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]) }) diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 676830733..89e000dd6 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -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}`)