create a loadFromDraft method

This commit is contained in:
greenart7c3
2024-03-18 09:09:00 -03:00
parent 0a20d5484b
commit 3cc32ecd9a
2 changed files with 114 additions and 104 deletions
@@ -185,6 +185,7 @@ fun NewPostView(
quote: Note? = null,
fork: Note? = null,
version: Note? = null,
draft: Note? = null,
enableMessageInterface: Boolean = false,
accountViewModel: AccountViewModel,
nav: (String) -> Unit,
@@ -201,7 +202,7 @@ fun NewPostView(
LaunchedEffect(Unit) {
launch(Dispatchers.IO) {
postViewModel.load(accountViewModel, baseReplyTo, quote, fork, version)
postViewModel.load(accountViewModel, baseReplyTo, quote, fork, version, draft)
postViewModel.imageUploadingError.collect { error ->
withContext(Dispatchers.Main) { Toast.makeText(context, error, Toast.LENGTH_SHORT).show() }
@@ -184,10 +184,14 @@ open class NewPostViewModel() : ViewModel() {
quote: Note?,
fork: Note?,
version: Note?,
draft: Note?,
) {
this.accountViewModel = accountViewModel
this.account = accountViewModel.account
if (draft != null) {
loadfromDraft(draft)
} else {
originalNote = replyingTo
replyingTo?.let { replyNote ->
if (replyNote.event is BaseTextNoteEvent) {
@@ -299,6 +303,11 @@ open class NewPostViewModel() : ViewModel() {
wantsForwardZapTo = true
}
}
}
private fun loadfromDraft(draft: Note?) {
// TODO: finish the loadfromDraft method
}
fun sendPost(
relayList: List<Relay>? = null,