Fixes recreating the new post screen from intent when switching accounts.

This commit is contained in:
Vitor Pamplona 2024-10-16 13:33:46 -04:00
parent 236ff2d680
commit c5dd2c5651
2 changed files with 20 additions and 5 deletions

View File

@ -140,7 +140,10 @@ class Amethyst : Application() {
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
println("Trim Memory $level")
GlobalScope.launch(Dispatchers.Default) { serviceManager.trimMemory() }
GlobalScope.launch(Dispatchers.Default) {
println("Trim Memory Inside $level")
serviceManager.trimMemory()
}
}
companion object {

View File

@ -336,13 +336,25 @@ private fun NavigateIfIntentRequested(
var newAccount by remember { mutableStateOf<String?>(null) }
if (activity.intent.action == Intent.ACTION_SEND) {
activity.intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
nav.newStack(buildNewPostRoute(draftMessage = it))
// saves the intent to avoid processing again
var message by remember {
mutableStateOf(
activity.intent.getStringExtra(Intent.EXTRA_TEXT)?.let {
it.ifBlank { null }
},
)
}
(activity.intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri)?.let {
nav.newStack(buildNewPostRoute(attachment = it))
var media by remember {
mutableStateOf(
(activity.intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri),
)
}
nav.newStack(buildNewPostRoute(draftMessage = message, attachment = media))
media = null
message = null
} else {
var currentIntentNextPage by remember {
mutableStateOf(