Adds draft editing to long form posting
This commit is contained in:
@@ -39,6 +39,7 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent
|
|||||||
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey
|
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey
|
||||||
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable
|
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable
|
||||||
import com.vitorpamplona.quartz.nip22Comments.CommentEvent
|
import com.vitorpamplona.quartz.nip22Comments.CommentEvent
|
||||||
|
import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent
|
||||||
import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent
|
import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent
|
||||||
import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel
|
import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel
|
||||||
import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
|
import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
|
||||||
@@ -330,6 +331,10 @@ suspend fun routeEditDraftTo(
|
|||||||
Route.NewShortNote(draft = note.idHex)
|
Route.NewShortNote(draft = note.idHex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is LongTextNoteEvent -> {
|
||||||
|
Route.NewLongFormPost(draft = note.idHex)
|
||||||
|
}
|
||||||
|
|
||||||
is ClassifiedsEvent -> {
|
is ClassifiedsEvent -> {
|
||||||
Route.NewProduct(draft = note.idHex)
|
Route.NewProduct(draft = note.idHex)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -201,7 +201,7 @@ private fun MarkdownPostScreenBody(
|
|||||||
.padding(horizontal = Size10dp, vertical = Size5dp),
|
.padding(horizontal = Size10dp, vertical = Size5dp),
|
||||||
textStyle =
|
textStyle =
|
||||||
LocalTextStyle.current.copy(
|
LocalTextStyle.current.copy(
|
||||||
fontSize = 20.sp,
|
fontSize = 18.sp,
|
||||||
textDirection = TextDirection.Content,
|
textDirection = TextDirection.Content,
|
||||||
),
|
),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
|
|||||||
+8
-5
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip23LongForm
|
||||||
|
|
||||||
|
import android.R.attr.version
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -201,7 +202,6 @@ class LongFormPostViewModel :
|
|||||||
fun hasLnAddress(): Boolean = account.userProfile().lnAddress() != null
|
fun hasLnAddress(): Boolean = account.userProfile().lnAddress() != null
|
||||||
|
|
||||||
// Editing existing article
|
// Editing existing article
|
||||||
var editingNote: Note? by mutableStateOf(null)
|
|
||||||
var existingDTag: String? = null
|
var existingDTag: String? = null
|
||||||
|
|
||||||
fun init(accountVM: AccountViewModel) {
|
fun init(accountVM: AccountViewModel) {
|
||||||
@@ -244,7 +244,6 @@ class LongFormPostViewModel :
|
|||||||
coverImageUrl = noteEvent.image() ?: ""
|
coverImageUrl = noteEvent.image() ?: ""
|
||||||
message = TextFieldValue(noteEvent.content)
|
message = TextFieldValue(noteEvent.content)
|
||||||
existingDTag = noteEvent.dTag()
|
existingDTag = noteEvent.dTag()
|
||||||
editingNote = version
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val user = account.userProfile()
|
val user = account.userProfile()
|
||||||
@@ -263,6 +262,13 @@ class LongFormPostViewModel :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadFromDraft(draftEvent: LongTextNoteEvent) {
|
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
|
canAddInvoice = accountViewModel.userProfile().lnAddress() != null
|
||||||
canAddZapRaiser = accountViewModel.userProfile().lnAddress() != null
|
canAddZapRaiser = accountViewModel.userProfile().lnAddress() != null
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
@@ -301,8 +307,6 @@ class LongFormPostViewModel :
|
|||||||
wantsForwardZapTo = true
|
wantsForwardZapTo = true
|
||||||
}
|
}
|
||||||
|
|
||||||
message = TextFieldValue(draftEvent.content)
|
|
||||||
|
|
||||||
iMetaAttachments.addAll(draftEvent.imetas())
|
iMetaAttachments.addAll(draftEvent.imetas())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,7 +564,6 @@ class LongFormPostViewModel :
|
|||||||
publishedAt = TimeUtils.now()
|
publishedAt = TimeUtils.now()
|
||||||
showPreview = false
|
showPreview = false
|
||||||
|
|
||||||
editingNote = null
|
|
||||||
existingDTag = null
|
existingDTag = null
|
||||||
|
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
|
|||||||
Reference in New Issue
Block a user