fix: Use unformatted status content in deleteAndRedraft (#1340)

* Use unformatted status content in deleteAndRedraft

* deleteStatus always returns an object even when the deletion fails

* throw error

fixes #1340
This commit is contained in:
Louise de Beaufort 2019-07-19 17:09:52 +02:00 committed by Nolan Lawson
parent a6235ded8c
commit e5df77b2a8
2 changed files with 5 additions and 3 deletions

View file

@ -6,11 +6,13 @@ import { deleteStatus as deleteStatusLocally } from './deleteStatuses'
export async function doDeleteStatus (statusId) { export async function doDeleteStatus (statusId) {
let { currentInstance, accessToken } = store.get() let { currentInstance, accessToken } = store.get()
try { try {
await deleteStatus(currentInstance, accessToken, statusId) let deletedStatus = await deleteStatus(currentInstance, accessToken, statusId)
deleteStatusLocally(currentInstance, statusId) deleteStatusLocally(currentInstance, statusId)
toast.say('Status deleted.') toast.say('Status deleted.')
return deletedStatus
} catch (e) { } catch (e) {
console.error(e) console.error(e)
toast.say('Unable to delete status: ' + (e.message || '')) toast.say('Unable to delete status: ' + (e.message || ''))
throw e
} }
} }

View file

@ -6,10 +6,10 @@ import { store } from '../_store/store'
export async function deleteAndRedraft (status) { export async function deleteAndRedraft (status) {
let deleteStatusPromise = doDeleteStatus(status.id) let deleteStatusPromise = doDeleteStatus(status.id)
let dialogPromise = importShowComposeDialog() let dialogPromise = importShowComposeDialog()
await deleteStatusPromise let deletedStatus = await deleteStatusPromise
store.setComposeData('dialog', { store.setComposeData('dialog', {
text: statusHtmlToPlainText(status.content, status.mentions), text: deletedStatus.text || statusHtmlToPlainText(status.content, status.mentions),
contentWarningShown: !!status.spoiler_text, contentWarningShown: !!status.spoiler_text,
contentWarning: status.spoiler_text || '', contentWarning: status.spoiler_text || '',
postPrivacy: status.visibility, postPrivacy: status.visibility,