Intercepts backhandler to save drafts
This commit is contained in:
+9
@@ -21,6 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.note.nip22Comments
|
package com.vitorpamplona.amethyst.ui.note.nip22Comments
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -135,6 +136,14 @@ fun GenericCommentPostScreen(
|
|||||||
) {
|
) {
|
||||||
WatchAndLoadMyEmojiList(accountViewModel)
|
WatchAndLoadMyEmojiList(accountViewModel)
|
||||||
|
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
postViewModel.sendDraftSync()
|
||||||
|
postViewModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
PostingTopBar(
|
PostingTopBar(
|
||||||
|
|||||||
+9
@@ -21,6 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.send
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.send
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
|
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -165,6 +166,14 @@ fun NewGroupDMScreen(
|
|||||||
|
|
||||||
WatchAndLoadMyEmojiList(accountViewModel)
|
WatchAndLoadMyEmojiList(accountViewModel)
|
||||||
|
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
postViewModel.sendDraftSync()
|
||||||
|
postViewModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
PostingTopBar(
|
PostingTopBar(
|
||||||
|
|||||||
+9
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.send
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.send
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
@@ -79,6 +80,14 @@ fun PrivateMessageEditFieldRow(
|
|||||||
onSendNewMessage: () -> Unit,
|
onSendNewMessage: () -> Unit,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
channelScreenModel.sendDraftSync()
|
||||||
|
channelScreenModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
channelScreenModel.replyTo.value?.let {
|
channelScreenModel.replyTo.value?.let {
|
||||||
DisplayReplyingToNote(it, accountViewModel, nav) {
|
DisplayReplyingToNote(it, accountViewModel, nav) {
|
||||||
channelScreenModel.clearReply()
|
channelScreenModel.clearReply()
|
||||||
|
|||||||
+9
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.send
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.send
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
@@ -60,6 +61,14 @@ fun EditFieldRow(
|
|||||||
onSendNewMessage: suspend () -> Unit,
|
onSendNewMessage: suspend () -> Unit,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
channelScreenModel.sendDraftSync()
|
||||||
|
channelScreenModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
channelScreenModel.replyTo.value?.let {
|
channelScreenModel.replyTo.value?.let {
|
||||||
DisplayReplyingToNote(it, accountViewModel, nav) {
|
DisplayReplyingToNote(it, accountViewModel, nav) {
|
||||||
channelScreenModel.clearReply()
|
channelScreenModel.clearReply()
|
||||||
|
|||||||
+9
@@ -21,6 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -136,6 +137,14 @@ fun NewProductScreen(
|
|||||||
) {
|
) {
|
||||||
WatchAndLoadMyEmojiList(accountViewModel)
|
WatchAndLoadMyEmojiList(accountViewModel)
|
||||||
|
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
postViewModel.sendDraftSync()
|
||||||
|
postViewModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
PostingTopBar(
|
PostingTopBar(
|
||||||
|
|||||||
+9
@@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.home
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -164,6 +165,14 @@ private fun NewPostScreenInner(
|
|||||||
) {
|
) {
|
||||||
WatchAndLoadMyEmojiList(accountViewModel)
|
WatchAndLoadMyEmojiList(accountViewModel)
|
||||||
|
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
postViewModel.sendDraftSync()
|
||||||
|
postViewModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
PostingTopBar(
|
PostingTopBar(
|
||||||
|
|||||||
+9
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.publicMessages
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.publicMessages
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
|
import androidx.compose.foundation.layout.Arrangement.Absolute.spacedBy
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@@ -128,6 +129,14 @@ fun NewPublicMessageScreen(
|
|||||||
|
|
||||||
WatchAndLoadMyEmojiList(accountViewModel)
|
WatchAndLoadMyEmojiList(accountViewModel)
|
||||||
|
|
||||||
|
BackHandler {
|
||||||
|
accountViewModel.runIOCatching {
|
||||||
|
postViewModel.sendDraftSync()
|
||||||
|
postViewModel.cancel()
|
||||||
|
}
|
||||||
|
nav.popBack()
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
PostingTopBar(
|
PostingTopBar(
|
||||||
|
|||||||
Reference in New Issue
Block a user