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