Skip to content

Commit

Permalink
Moved intent processor to Compose pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Mora Gras <[email protected]>
  • Loading branch information
ArnyminerZ committed Mar 14, 2024
1 parent fd83d36 commit c20f304
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,6 @@ class AddCalendarActivity : AppCompatActivity() {
override fun onCreate(inState: Bundle?) {
super.onCreate(inState)

if (inState == null) {
intent?.apply {
data?.toString()
?.let(subscriptionSettingsModel.url::postValue)
?.also { checkUrlIntroductionPage() }
getStringExtra(EXTRA_TITLE)
?.let(subscriptionSettingsModel.title::postValue)
takeIf { hasExtra(EXTRA_COLOR) }
?.getIntExtra(EXTRA_COLOR, LocalCalendar.DEFAULT_COLOR)
?.let(subscriptionSettingsModel.color::postValue)
}
}

subscriptionModel.success.observe(this) { success ->
if (success) {
// success, show notification and close activity
Expand Down Expand Up @@ -133,6 +120,21 @@ class AddCalendarActivity : AppCompatActivity() {
val isCreating: Boolean by subscriptionModel.isCreating.observeAsState(false)
val showNextButton by subscriptionModel.showNextButton.observeAsState(false)

LaunchedEffect(intent) {
if (inState == null) {
intent?.apply {
data?.toString()
?.let(subscriptionSettingsModel.url::postValue)
?.also { checkUrlIntroductionPage() }
getStringExtra(EXTRA_TITLE)
?.let(subscriptionSettingsModel.title::postValue)
takeIf { hasExtra(EXTRA_COLOR) }
?.getIntExtra(EXTRA_COLOR, LocalCalendar.DEFAULT_COLOR)
?.let(subscriptionSettingsModel.color::postValue)
}
}
}

// Receive updates for the URL introduction page
LaunchedEffect(url, requiresAuth, username, password, isVerifyingUrl) {
checkUrlIntroductionPage()
Expand Down

0 comments on commit c20f304

Please sign in to comment.