mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Fix multi-account announcement never being displayed
This commit is contained in:
committed by
Benoit Marty
parent
86e72ac11e
commit
72f4c4f897
+2
-2
@@ -40,11 +40,11 @@ class DefaultAnnouncementStore(
|
||||
// NOT replay on first launch.
|
||||
// - Fullscreen.Space is disabled
|
||||
// - NewNotificationSound is opted in by AppMigration08
|
||||
// - MultiAccount is opted in by AppMigration11
|
||||
// - MultiAccount is NeverShown by default, AppMigration11 sets it to Show or Shown.
|
||||
val defaultStatus = when (announcement) {
|
||||
Announcement.Fullscreen.Space -> AnnouncementStatus.Shown
|
||||
Announcement.NewNotificationSound -> AnnouncementStatus.Shown
|
||||
Announcement.MultiAccount -> AnnouncementStatus.Shown
|
||||
Announcement.MultiAccount -> AnnouncementStatus.NeverShown
|
||||
}
|
||||
return store.data.map { prefs ->
|
||||
val ordinal = prefs[key] ?: defaultStatus.ordinal
|
||||
|
||||
+3
-4
@@ -16,6 +16,7 @@ import io.element.android.libraries.sessionstorage.api.SessionStore
|
||||
/**
|
||||
* Ensure the multi-account announcement is displayed, but only on application upgrade,
|
||||
* and only if the user does not already have several accounts.
|
||||
* In the other cases, mark the announcement as already shown.
|
||||
*/
|
||||
@ContributesIntoSet(AppScope::class)
|
||||
class AppMigration11(
|
||||
@@ -25,10 +26,8 @@ class AppMigration11(
|
||||
override val order: Int = 11
|
||||
|
||||
override suspend fun migrate(isFreshInstall: Boolean) {
|
||||
if (isFreshInstall) return
|
||||
|
||||
if (sessionStore.getAllSessions().size > 1) {
|
||||
// The user already uses several accounts, no need to announce the feature
|
||||
if (isFreshInstall || sessionStore.getAllSessions().size > 1) {
|
||||
// New users, or users who already have several accounts, do not need to be informed about the feature
|
||||
announcementService.onAnnouncementDismissed(Announcement.MultiAccount)
|
||||
} else {
|
||||
announcementService.showAnnouncement(Announcement.MultiAccount)
|
||||
|
||||
+7
-3
@@ -18,14 +18,18 @@ import org.junit.Test
|
||||
|
||||
class AppMigration11Test {
|
||||
@Test
|
||||
fun `migration on fresh install should not invoke the AnnouncementService`() = runTest {
|
||||
val service = FakeAnnouncementService()
|
||||
fun `migration on fresh install should mark the announcement as dismissed`() = runTest {
|
||||
val onAnnouncementDismissedResult = lambdaRecorder<Announcement, Unit> { }
|
||||
val service = FakeAnnouncementService(
|
||||
onAnnouncementDismissedResult = onAnnouncementDismissedResult,
|
||||
)
|
||||
val migration = AppMigration11(
|
||||
sessionStore = InMemorySessionStore(initialList = listOf(aSessionData())),
|
||||
announcementService = service,
|
||||
)
|
||||
// FakeAnnouncementService lambdas throw by default
|
||||
migration.migrate(isFreshInstall = true)
|
||||
onAnnouncementDismissedResult.assertions().isCalledOnce()
|
||||
.with(value(Announcement.MultiAccount))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user