From fd27c78c4b85ff889833bd247ab0cfc53ad7b176 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 14 Jan 2019 22:58:23 +0300 Subject: [PATCH] fixes, guards --- src/modules/statuses.js | 2 +- src/services/api/api.service.js | 14 +++++++++++++- .../status_normalizer/status_normalizer.service.js | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 88791191..73d034f1 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -300,7 +300,7 @@ export const mutations = { }, clearTimeline (state, { timeline }) { const timelineObject = typeof timeline === 'object' ? timeline : state.timelines[timeline] - emptyTl(timelineObject, state.timelines[timeline].userId) + emptyTl(timelineObject, timeline.userId) }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index b6180403..e82f4f81 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -277,6 +277,12 @@ const fetchConversation = ({id, credentials}) => { let url = `${CONVERSATION_URL}/${id}.json?count=100` return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) + .then((data) => { + if (data.ok) { + return data + } + throw new Error('Error fetching timeline') + }) .then((data) => data.map(parseStatus)) } @@ -284,7 +290,13 @@ const fetchStatus = ({id, credentials}) => { let url = `${STATUS_URL}/${id}.json` return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) - .then((data) => data.map(parseStatus)) + .then((data) => { + if (data.ok) { + return data + } + throw new Error('Error fetching timeline') + }) + .then((data) => parseStatus(data)) } const setUserMute = ({id, credentials, muted = true}) => { diff --git a/src/services/status_normalizer/status_normalizer.service.js b/src/services/status_normalizer/status_normalizer.service.js index 0dbceaa4..5ca5a279 100644 --- a/src/services/status_normalizer/status_normalizer.service.js +++ b/src/services/status_normalizer/status_normalizer.service.js @@ -117,11 +117,15 @@ export const parseStatus = (data) => { output.nsfw = data.sensitive output.statusnet_html = data.content - // Not exactly the same... + + // Not exactly the same but works? output.text = data.content output.in_reply_to_status_id = data.in_reply_to_id output.in_reply_to_user_id = data.in_reply_to_user_id + + // Not exactly the same but works + output.statusnet_conversation_id = data.id } else { output.favorited = data.favorited output.fave_num = data.fave_num @@ -145,6 +149,8 @@ export const parseStatus = (data) => { output.in_reply_to_status_id = data.in_reply_to_id output.in_reply_to_user_id = data.in_reply_to_account_id + + output.statusnet_conversation_id = data.statusnet_conversation_id } output.id = Number(data.id)