1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Basic editing works

This commit is contained in:
Zhiyuan Zheng
2022-04-30 17:44:39 +02:00
parent 95ec76f411
commit d4f91a5756
17 changed files with 220 additions and 71 deletions

View File

@@ -39,6 +39,7 @@ const composeParseState = (
): ComposeState => {
switch (params.type) {
case 'edit':
case 'deleteEdit':
return {
...composeInitialState,
dirty: true,

View File

@@ -51,8 +51,11 @@ const composePost = async (
formData.append('visibility', composeState.visibility)
return apiInstance<Mastodon.Status>({
method: 'post',
url: 'statuses',
method: params?.type === 'edit' ? 'put' : 'post',
url:
params?.type === 'edit'
? `statuses/${params.incomingStatus.id}`
: 'statuses',
headers: {
'Idempotency-Key': await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
@@ -67,7 +70,9 @@ const composePost = async (
composeState.attachments.sensitive +
composeState.attachments.uploads.map(upload => upload.remote?.id) +
composeState.visibility +
(params?.type === 'edit' ? Math.random() : '')
(params?.type === 'edit' || params?.type === 'deleteEdit'
? Math.random()
: '')
)
},
body: formData