Add ability to view status history for edited statuses

This commit is contained in:
Sean King 2022-06-20 22:52:08 -06:00
commit fa5d35523d
No known key found for this signature in database
GPG key ID: 510C52BACD6E7257
12 changed files with 186 additions and 13 deletions

View file

@ -425,17 +425,16 @@ const fetchStatusSource = ({ id, credentials }) => {
.then((data) => parseSource(data))
}
const fetchStatusHistory = ({ id, credentials }) => {
let url = MASTODON_STATUS_HISTORY_URL(id)
return fetch(url, { headers: authHeaders(credentials) })
const fetchStatusHistory = ({ status, credentials }) => {
let url = MASTODON_STATUS_HISTORY_URL(status.id)
return promisedRequest({ url, credentials })
.then((data) => {
if (data.ok) {
return data
}
throw new Error('Error fetching history', data)
data.reverse()
return data.map((item) => {
item.originalStatus = status
return parseStatus(item)
})
})
.then((data) => data.json())
.then((data) => parseStatus(data))
}
const tagUser = ({ tag, credentials, user }) => {

View file

@ -275,7 +275,7 @@ export const parseStatus = (data) => {
output.tags = data.tags
output.is_edited = data.edited_at !== null
output.edited_at = data.edited_at
if (data.pleroma) {
const { pleroma } = data
@ -378,6 +378,10 @@ export const parseStatus = (data) => {
output.favoritedBy = []
output.rebloggedBy = []
if (data.hasOwnProperty('originalStatus')) {
Object.assign(output, data.originalStatus)
}
return output
}