Skip to content

Commit

Permalink
Fixes recreating the new post screen from intent when switching accou…
Browse files Browse the repository at this point in the history
…nts.
  • Loading branch information
vitorpamplona committed Oct 16, 2024
1 parent 236ff2d commit c5dd2c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c5dd2c5

Please sign in to comment.