From 4e25ecd34cf9f0e49671cfaee56585e3f82d91c7 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 5 Oct 2026 18:01:54 +0200 Subject: [PATCH] Dismiss the multi-account announcement when the user has several accounts If the announcement was queued at upgrade while the user had a single account, and the user then added another account without seeing it, the announcement stayed pending and was shown later if the user removed an account. Mark it as dismissed as soon as several accounts are detected. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../android/features/home/impl/HomePresenter.kt | 15 +++++++++++++++ .../features/home/impl/HomePresenterTest.kt | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt index 7c43d6a90c..95c98a4aec 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt @@ -35,6 +35,7 @@ import io.element.android.libraries.matrix.api.sync.SyncService import io.element.android.libraries.sessionstorage.api.SessionStore import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.filter import kotlinx.coroutines.launch @Inject @@ -75,6 +76,20 @@ class HomePresenter( isMultiAccountEnabled && sessions.size == 1 && announcements.contains(Announcement.MultiAccount) } }.collectAsState(false) + LaunchedEffect(Unit) { + // The user already uses several accounts, so the feature does not need to be announced anymore, + // even if they later remove accounts. + combine( + announcementService.announcementsToShowFlow(), + sessionStore.sessionsFlow(), + ) { announcements, sessions -> + announcements.contains(Announcement.MultiAccount) && sessions.size > 1 + } + .filter { it } + .collect { + announcementService.onAnnouncementDismissed(Announcement.MultiAccount) + } + } val roomListState = roomListPresenter.present() val homeSpacesState = homeSpacesPresenter.present() var currentHomeNavigationBarItemOrdinal by rememberSaveable { mutableIntStateOf(HomeNavigationBarItem.Chats.ordinal) } diff --git a/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt b/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt index 2f6971da8b..d4b03b68c7 100644 --- a/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt +++ b/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt @@ -193,7 +193,8 @@ class HomePresenterTest { } @Test - fun `present - multi account announcement is not shown when there are several accounts`() = runTest { + fun `present - multi account announcement is not shown and is dismissed when there are several accounts`() = runTest { + val onAnnouncementDismissedResult = lambdaRecorder { } val presenter = createHomePresenter( sessionStore = InMemorySessionStore( initialList = listOf( @@ -204,6 +205,7 @@ class HomePresenterTest { ), announcementService = FakeAnnouncementService( initialAnnouncementsToShowFlowValue = listOf(Announcement.MultiAccount), + onAnnouncementDismissedResult = onAnnouncementDismissedResult, ), featureFlagService = FakeFeatureFlagService( initialState = mapOf(FeatureFlags.MultiAccount.key to true), @@ -211,6 +213,8 @@ class HomePresenterTest { ) presenter.test { assertThat(expectMostRecentItem().showMultiAccountAnnouncement).isFalse() + onAnnouncementDismissedResult.assertions().isCalledOnce() + .with(value(Announcement.MultiAccount)) } }