From c20f304bbd7f2a01023c744838c4811c3423128d Mon Sep 17 00:00:00 2001 From: Arnau Mora Date: Thu, 14 Mar 2024 17:54:45 +0100 Subject: [PATCH] Moved intent processor to Compose pipeline Signed-off-by: Arnau Mora Gras --- .../icsdroid/ui/views/AddCalendarActivity.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/at/bitfire/icsdroid/ui/views/AddCalendarActivity.kt b/app/src/main/java/at/bitfire/icsdroid/ui/views/AddCalendarActivity.kt index 64e83951..f667bb87 100644 --- a/app/src/main/java/at/bitfire/icsdroid/ui/views/AddCalendarActivity.kt +++ b/app/src/main/java/at/bitfire/icsdroid/ui/views/AddCalendarActivity.kt @@ -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 @@ -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()