logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: e7fb5e81c31963cbd981d7a1e49c7d390a461336
parent b4cbbefbd2dac62a0e334da43d1e076d4bef00a7
Author: HJ <30-hj@users.noreply.git.pleroma.social>
Date:   Sun, 15 Jan 2023 12:36:44 +0000

Merge branch 'tusooa/nomore-mapundef' into 'develop'

Display better error message for unauthenticated timelines

Closes #1235 and #1044

See merge request pleroma/pleroma-fe!1756

Diffstat:

Msrc/services/api/api.service.js30+++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js @@ -734,26 +734,22 @@ const fetchTimeline = ({ const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&') url += `?${queryString}` - let status = '' - let statusText = '' - - let pagination = {} return fetch(url, { headers: authHeaders(credentials) }) - .then((data) => { - status = data.status - statusText = data.statusText - pagination = parseLinkHeaderPagination(data.headers.get('Link'), { - flakeId: timeline !== 'bookmarks' && timeline !== 'notifications' - }) - return data - }) - .then((data) => data.json()) - .then((data) => { - if (!data.errors) { + .then(async (response) => { + const success = response.ok + + const data = await response.json() + + if (success && !data.errors) { + const pagination = parseLinkHeaderPagination(response.headers.get('Link'), { + flakeId: timeline !== 'bookmarks' && timeline !== 'notifications' + }) + return { data: data.map(isNotifications ? parseNotification : parseStatus), pagination } } else { - data.status = status - data.statusText = statusText + data.errors ||= [] + data.status = response.status + data.statusText = response.statusText return data } })