Adds draft editing to long form posting

This commit is contained in:
Vitor Pamplona
2026-03-22 14:38:44 -04:00
parent 570639c1df
commit 9c30e2d0f6
3 changed files with 14 additions and 6 deletions
@@ -39,6 +39,7 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable
import com.vitorpamplona.quartz.nip22Comments.CommentEvent
import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent
import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent
import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel
import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
@@ -330,6 +331,10 @@ suspend fun routeEditDraftTo(
Route.NewShortNote(draft = note.idHex)
}
is LongTextNoteEvent -> {
Route.NewLongFormPost(draft = note.idHex)
}
is ClassifiedsEvent -> {
Route.NewProduct(draft = note.idHex)
}
@@ -201,7 +201,7 @@ private fun MarkdownPostScreenBody(
.padding(horizontal = Size10dp, vertical = Size5dp),
textStyle =
LocalTextStyle.current.copy(
fontSize = 20.sp,
fontSize = 18.sp,
textDirection = TextDirection.Content,
),
singleLine = true,
@@ -20,6 +20,7 @@
*/
package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm
import android.R.attr.version
import android.content.Context
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
@@ -201,7 +202,6 @@ class LongFormPostViewModel :
fun hasLnAddress(): Boolean = account.userProfile().lnAddress() != null
// Editing existing article
var editingNote: Note? by mutableStateOf(null)
var existingDTag: String? = null
fun init(accountVM: AccountViewModel) {
@@ -244,7 +244,6 @@ class LongFormPostViewModel :
coverImageUrl = noteEvent.image() ?: ""
message = TextFieldValue(noteEvent.content)
existingDTag = noteEvent.dTag()
editingNote = version
}
val user = account.userProfile()
@@ -263,6 +262,13 @@ class LongFormPostViewModel :
}
private fun loadFromDraft(draftEvent: LongTextNoteEvent) {
title = TextFieldValue(draftEvent.title() ?: "")
summary = TextFieldValue(draftEvent.summary() ?: "")
publishedAt = draftEvent.publishedAt() ?: draftEvent.createdAt
coverImageUrl = draftEvent.image() ?: ""
message = TextFieldValue(draftEvent.content)
existingDTag = draftEvent.dTag()
canAddInvoice = accountViewModel.userProfile().lnAddress() != null
canAddZapRaiser = accountViewModel.userProfile().lnAddress() != null
multiOrchestrator = null
@@ -301,8 +307,6 @@ class LongFormPostViewModel :
wantsForwardZapTo = true
}
message = TextFieldValue(draftEvent.content)
iMetaAttachments.addAll(draftEvent.imetas())
}
@@ -560,7 +564,6 @@ class LongFormPostViewModel :
publishedAt = TimeUtils.now()
showPreview = false
editingNote = null
existingDTag = null
multiOrchestrator = null