From 859b0e1b60cd876e8a2f901a5f6ef635c3f1df77 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 25 Aug 2026 10:13:33 +0200 Subject: [PATCH] `BugReportEvents` -> `BugReportEvent` --- .../{BugReportEvents.kt => BugReportEvent.kt} | 20 ++++---- .../impl/bugreport/BugReportPresenter.kt | 20 ++++---- .../impl/bugreport/BugReportState.kt | 2 +- .../rageshake/impl/bugreport/BugReportView.kt | 20 ++++---- .../impl/bugreport/BugReportPresenterTest.kt | 46 +++++++++---------- 5 files changed, 54 insertions(+), 54 deletions(-) rename features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/{BugReportEvents.kt => BugReportEvent.kt} (74%) diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportEvents.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportEvent.kt similarity index 74% rename from features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportEvents.kt rename to features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportEvent.kt index 94897d1bad..448f5a9d87 100644 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportEvents.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportEvent.kt @@ -8,15 +8,15 @@ package io.element.android.features.rageshake.impl.bugreport -sealed interface BugReportEvents { - data object SendBugReport : BugReportEvents - data object ResetAll : BugReportEvents - data object ClearError : BugReportEvents +sealed interface BugReportEvent { + data object SendBugReport : BugReportEvent + data object ResetAll : BugReportEvent + data object ClearError : BugReportEvent - data class SetDescription(val description: String) : BugReportEvents - data class SetSendLog(val sendLog: Boolean) : BugReportEvents - data class SetCanContact(val canContact: Boolean) : BugReportEvents - data class SetSendScreenshot(val sendScreenshot: Boolean) : BugReportEvents - data class SetSendPushRules(val sendPushRules: Boolean) : BugReportEvents - data class SetGhIssueNumber(val ghIssueNumber: Int?) : BugReportEvents + data class SetDescription(val description: String) : BugReportEvent + data class SetSendLog(val sendLog: Boolean) : BugReportEvent + data class SetCanContact(val canContact: Boolean) : BugReportEvent + data class SetSendScreenshot(val sendScreenshot: Boolean) : BugReportEvent + data class SetSendPushRules(val sendPushRules: Boolean) : BugReportEvent + data class SetGhIssueNumber(val ghIssueNumber: Int?) : BugReportEvent } diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenter.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenter.kt index c7c706fa68..607653baa4 100644 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenter.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenter.kt @@ -83,9 +83,9 @@ class BugReportPresenter( } val uploadListener = BugReporterUploadListener(sendingProgress, sendingAction) - fun handleEvent(event: BugReportEvents) { + fun handleEvent(event: BugReportEvent) { when (event) { - BugReportEvents.SendBugReport -> { + BugReportEvent.SendBugReport -> { if (formState.value.description.length < 10 && formState.value.ghIssueNumber == null) { sendingAction.value = AsyncAction.Failure(BugReportFormError.DescriptionTooShort) } else { @@ -93,27 +93,27 @@ class BugReportPresenter( appCoroutineScope.sendBugReport(formState.value, crashInfo.isNotEmpty(), uploadListener) } } - BugReportEvents.ResetAll -> appCoroutineScope.resetAll() - is BugReportEvents.SetDescription -> updateFormState(formState) { + BugReportEvent.ResetAll -> appCoroutineScope.resetAll() + is BugReportEvent.SetDescription -> updateFormState(formState) { copy(description = event.description) } - is BugReportEvents.SetCanContact -> updateFormState(formState) { + is BugReportEvent.SetCanContact -> updateFormState(formState) { copy(canContact = event.canContact) } - is BugReportEvents.SetSendLog -> updateFormState(formState) { + is BugReportEvent.SetSendLog -> updateFormState(formState) { copy(sendLogs = event.sendLog) } - is BugReportEvents.SetSendScreenshot -> updateFormState(formState) { + is BugReportEvent.SetSendScreenshot -> updateFormState(formState) { copy(sendScreenshot = event.sendScreenshot) } - is BugReportEvents.SetSendPushRules -> updateFormState(formState) { + is BugReportEvent.SetSendPushRules -> updateFormState(formState) { copy(sendPushRules = event.sendPushRules) } - BugReportEvents.ClearError -> { + BugReportEvent.ClearError -> { sendingProgress.floatValue = 0f sendingAction.value = AsyncAction.Uninitialized } - is BugReportEvents.SetGhIssueNumber -> updateFormState(formState) { + is BugReportEvent.SetGhIssueNumber -> updateFormState(formState) { copy(ghIssueNumber = event.ghIssueNumber) } } diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportState.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportState.kt index 8e07b3c4e8..4ec5710cc6 100644 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportState.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportState.kt @@ -18,7 +18,7 @@ data class BugReportState( val screenshotUri: String?, val sendingProgress: Float, val sending: AsyncAction, - val eventSink: (BugReportEvents) -> Unit + val eventSink: (BugReportEvent) -> Unit ) { val submitEnabled = sending !is AsyncAction.Loading val isDescriptionInError = sending is AsyncAction.Failure && diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt index 2c8dba4af3..9c1c25e153 100644 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportView.kt @@ -84,7 +84,7 @@ fun BugReportView( supportingText = stringResource(id = R.string.screen_bug_report_editor_description), onValueChange = { descriptionFieldState = it - eventSink(BugReportEvents.SetDescription(it)) + eventSink(BugReportEvent.SetDescription(it)) }, keyboardOptions = KeyboardOptions( capitalization = KeyboardCapitalization.Sentences, @@ -110,14 +110,14 @@ fun BugReportView( PreferenceDivider() PreferenceSwitch( isChecked = state.formState.sendLogs, - onCheckedChange = { eventSink(BugReportEvents.SetSendLog(it)) }, + onCheckedChange = { eventSink(BugReportEvent.SetSendLog(it)) }, enabled = isFormEnabled, title = stringResource(id = R.string.screen_bug_report_include_logs), subtitle = stringResource(id = R.string.screen_bug_report_logs_description), ) PreferenceSwitch( isChecked = state.formState.canContact, - onCheckedChange = { eventSink(BugReportEvents.SetCanContact(it)) }, + onCheckedChange = { eventSink(BugReportEvent.SetCanContact(it)) }, enabled = isFormEnabled, title = stringResource(id = R.string.screen_bug_report_contact_me_title), subtitle = stringResource(id = R.string.screen_bug_report_contact_me), @@ -125,7 +125,7 @@ fun BugReportView( if (state.screenshotUri != null) { PreferenceSwitch( isChecked = state.formState.sendScreenshot, - onCheckedChange = { eventSink(BugReportEvents.SetSendScreenshot(it)) }, + onCheckedChange = { eventSink(BugReportEvent.SetSendScreenshot(it)) }, enabled = isFormEnabled, title = stringResource(id = R.string.screen_bug_report_include_screenshot) ) @@ -151,7 +151,7 @@ fun BugReportView( } PreferenceSwitch( isChecked = state.formState.sendPushRules, - onCheckedChange = { eventSink(BugReportEvents.SetSendPushRules(it)) }, + onCheckedChange = { eventSink(BugReportEvent.SetSendPushRules(it)) }, enabled = isFormEnabled, title = stringResource(R.string.screen_bug_report_send_notification_settings_title), subtitle = stringResource(R.string.screen_bug_report_send_notification_settings_description), @@ -179,12 +179,12 @@ fun BugReportView( onValueChange = { if (it.isEmpty()) { ghIssueNumberState = "" - eventSink(BugReportEvents.SetGhIssueNumber(null)) + eventSink(BugReportEvent.SetGhIssueNumber(null)) } else { val number = it.toIntOrNull()?.takeIf { ghInt -> ghInt in 1..99_999 } number?.let { ghIssueNumber -> ghIssueNumberState = ghIssueNumber.toString() - eventSink(BugReportEvents.SetGhIssueNumber(ghIssueNumber)) + eventSink(BugReportEvent.SetGhIssueNumber(ghIssueNumber)) } } }, @@ -202,7 +202,7 @@ fun BugReportView( PreferenceRow { Button( text = stringResource(id = CommonStrings.action_send), - onClick = { eventSink(BugReportEvents.SendBugReport) }, + onClick = { eventSink(BugReportEvent.SendBugReport) }, enabled = state.submitEnabled, showProgress = state.sending.isLoading(), modifier = Modifier @@ -216,7 +216,7 @@ fun BugReportView( async = state.sending, progressDialog = { }, onSuccess = { - eventSink(BugReportEvents.ResetAll) + eventSink(BugReportEvent.ResetAll) onSuccess() }, errorMessage = { error -> @@ -225,7 +225,7 @@ fun BugReportView( else -> error.message ?: error.toString() } }, - onErrorDismiss = { eventSink(BugReportEvents.ClearError) }, + onErrorDismiss = { eventSink(BugReportEvent.ClearError) }, ) } } diff --git a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt index afbcc939a6..904ff881f0 100644 --- a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt +++ b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt @@ -51,9 +51,9 @@ class BugReportPresenterTest { val presenter = createPresenter() presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetDescription(A_SHORT_DESCRIPTION)) + initialState.eventSink.invoke(BugReportEvent.SetDescription(A_SHORT_DESCRIPTION)) assertThat(awaitItem().submitEnabled).isTrue() - initialState.eventSink.invoke(BugReportEvents.SetDescription(A_LONG_DESCRIPTION)) + initialState.eventSink.invoke(BugReportEvent.SetDescription(A_LONG_DESCRIPTION)) assertThat(awaitItem().submitEnabled).isTrue() } } @@ -63,9 +63,9 @@ class BugReportPresenterTest { val presenter = createPresenter() presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetCanContact(true)) + initialState.eventSink.invoke(BugReportEvent.SetCanContact(true)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(canContact = true)) - initialState.eventSink.invoke(BugReportEvents.SetCanContact(false)) + initialState.eventSink.invoke(BugReportEvent.SetCanContact(false)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(canContact = false)) } } @@ -76,9 +76,9 @@ class BugReportPresenterTest { presenter.test { val initialState = awaitItem() // Since this is true by default, start by disabling - initialState.eventSink.invoke(BugReportEvents.SetSendLog(false)) + initialState.eventSink.invoke(BugReportEvent.SetSendLog(false)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(sendLogs = false)) - initialState.eventSink.invoke(BugReportEvents.SetSendLog(true)) + initialState.eventSink.invoke(BugReportEvent.SetSendLog(true)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(sendLogs = true)) } } @@ -88,9 +88,9 @@ class BugReportPresenterTest { val presenter = createPresenter() presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetSendScreenshot(true)) + initialState.eventSink.invoke(BugReportEvent.SetSendScreenshot(true)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(sendScreenshot = true)) - initialState.eventSink.invoke(BugReportEvents.SetSendScreenshot(false)) + initialState.eventSink.invoke(BugReportEvent.SetSendScreenshot(false)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(sendScreenshot = false)) } } @@ -100,9 +100,9 @@ class BugReportPresenterTest { val presenter = createPresenter() presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetSendPushRules(true)) + initialState.eventSink.invoke(BugReportEvent.SetSendPushRules(true)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(sendPushRules = true)) - initialState.eventSink.invoke(BugReportEvents.SetSendPushRules(false)) + initialState.eventSink.invoke(BugReportEvent.SetSendPushRules(false)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(sendPushRules = false)) } } @@ -112,9 +112,9 @@ class BugReportPresenterTest { val presenter = createPresenter() presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetGhIssueNumber(1)) + initialState.eventSink.invoke(BugReportEvent.SetGhIssueNumber(1)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(ghIssueNumber = 1)) - initialState.eventSink.invoke(BugReportEvents.SetGhIssueNumber(null)) + initialState.eventSink.invoke(BugReportEvent.SetGhIssueNumber(null)) assertThat(awaitItem().formState).isEqualTo(BugReportFormState.Default.copy(ghIssueNumber = null)) } } @@ -130,7 +130,7 @@ class BugReportPresenterTest { val initialState = awaitItem() assertThat(initialState.hasCrashLogs).isTrue() assertThat(initialState.screenshotUri).isEqualTo(A_SCREENSHOT_URI) - initialState.eventSink.invoke(BugReportEvents.ResetAll) + initialState.eventSink.invoke(BugReportEvent.ResetAll) val resetState = awaitItem() assertThat(resetState.hasCrashLogs).isFalse() // TODO Make it live assertThat(resetState.screenshotUri).isNull() @@ -146,9 +146,9 @@ class BugReportPresenterTest { ) presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetDescription(A_LONG_DESCRIPTION)) + initialState.eventSink.invoke(BugReportEvent.SetDescription(A_LONG_DESCRIPTION)) skipItems(1) - initialState.eventSink.invoke(BugReportEvents.SendBugReport) + initialState.eventSink.invoke(BugReportEvent.SendBugReport) skipItems(1) val progressState = awaitItem() assertThat(progressState.sending).isEqualTo(AsyncAction.Loading) @@ -170,9 +170,9 @@ class BugReportPresenterTest { ) presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetDescription(A_LONG_DESCRIPTION)) + initialState.eventSink.invoke(BugReportEvent.SetDescription(A_LONG_DESCRIPTION)) skipItems(1) - initialState.eventSink.invoke(BugReportEvents.SendBugReport) + initialState.eventSink.invoke(BugReportEvent.SendBugReport) skipItems(1) val progressState = awaitItem() assertThat(progressState.sending).isEqualTo(AsyncAction.Loading) @@ -182,7 +182,7 @@ class BugReportPresenterTest { assertThat(awaitItem().sendingProgress).isEqualTo(0f) assertThat((awaitItem().sending as AsyncAction.Failure).error.message).isEqualTo(A_FAILURE_REASON) // Reset failure - initialState.eventSink.invoke(BugReportEvents.ClearError) + initialState.eventSink.invoke(BugReportEvent.ClearError) val lastItem = awaitItem() assertThat(lastItem.sendingProgress).isEqualTo(0f) assertThat(lastItem.sending).isInstanceOf(AsyncAction.Uninitialized::class.java) @@ -194,13 +194,13 @@ class BugReportPresenterTest { val presenter = createPresenter() presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetDescription(A_SHORT_DESCRIPTION)) + initialState.eventSink.invoke(BugReportEvent.SetDescription(A_SHORT_DESCRIPTION)) skipItems(1) - initialState.eventSink.invoke(BugReportEvents.SendBugReport) + initialState.eventSink.invoke(BugReportEvent.SendBugReport) val errorState = awaitItem() assertThat(errorState.sending).isEqualTo(AsyncAction.Failure(BugReportFormError.DescriptionTooShort)) // Reset failure - initialState.eventSink.invoke(BugReportEvents.ClearError) + initialState.eventSink.invoke(BugReportEvent.ClearError) val lastItem = awaitItem() assertThat(lastItem.sending).isInstanceOf(AsyncAction.Uninitialized::class.java) } @@ -215,9 +215,9 @@ class BugReportPresenterTest { ) presenter.test { val initialState = awaitItem() - initialState.eventSink.invoke(BugReportEvents.SetDescription(A_LONG_DESCRIPTION)) + initialState.eventSink.invoke(BugReportEvent.SetDescription(A_LONG_DESCRIPTION)) skipItems(1) - initialState.eventSink.invoke(BugReportEvents.SendBugReport) + initialState.eventSink.invoke(BugReportEvent.SendBugReport) skipItems(1) val progressState = awaitItem() assertThat(progressState.sending).isEqualTo(AsyncAction.Loading)