mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 08:15:02 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
+15
@@ -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) }
|
||||
|
||||
+5
-1
@@ -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<Announcement, Unit> { }
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user