2021-07-04 20:19:04 -07:00
|
|
|
import { statusHtmlToPlainText } from '../_utils/statusHtmlToPlainText.js'
|
2019-10-29 18:58:49 -07:00
|
|
|
import { importShowComposeDialog } from '../_components/dialog/asyncDialogs/importShowComposeDialog.js'
|
2021-07-04 20:19:04 -07:00
|
|
|
import { doDeleteStatus } from './delete.js'
|
|
|
|
import { store } from '../_store/store.js'
|
2018-12-19 00:57:56 -08:00
|
|
|
|
|
|
|
export async function deleteAndRedraft (status) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const deleteStatusPromise = doDeleteStatus(status.id)
|
|
|
|
const dialogPromise = importShowComposeDialog()
|
|
|
|
const deletedStatus = await deleteStatusPromise
|
2018-12-19 00:57:56 -08:00
|
|
|
|
|
|
|
store.setComposeData('dialog', {
|
2019-07-19 17:09:52 +02:00
|
|
|
text: deletedStatus.text || statusHtmlToPlainText(status.content, status.mentions),
|
2018-12-19 00:57:56 -08:00
|
|
|
contentWarningShown: !!status.spoiler_text,
|
|
|
|
contentWarning: status.spoiler_text || '',
|
|
|
|
postPrivacy: status.visibility,
|
|
|
|
media: status.media_attachments && status.media_attachments.map(_ => ({
|
|
|
|
description: _.description || '',
|
|
|
|
data: _
|
|
|
|
})),
|
2019-07-19 20:08:17 -07:00
|
|
|
inReplyToId: status.in_reply_to_id,
|
|
|
|
// note that for polls there is no real way to preserve the original expiry
|
|
|
|
poll: status.poll && {
|
|
|
|
multiple: !!status.poll.multiple,
|
|
|
|
options: (status.poll.options || []).map(option => option.title)
|
2019-09-17 00:19:53 -07:00
|
|
|
},
|
|
|
|
sensitive: !!status.sensitive
|
2018-12-19 00:57:56 -08:00
|
|
|
})
|
2019-08-03 13:49:37 -07:00
|
|
|
const showComposeDialog = await dialogPromise
|
2018-12-19 00:57:56 -08:00
|
|
|
showComposeDialog()
|
|
|
|
}
|