Merge pull request #3035 from element-hq/feature/bma/fixFdroidNotification
Feature/bma/fix fdroid notification
This commit is contained in:
commit
e4bfc5ef8f
43 changed files with 1060 additions and 106 deletions
|
|
@ -32,6 +32,9 @@ interface PreferencesEntryPoint : FeatureEntryPoint {
|
|||
|
||||
@Parcelize
|
||||
data object NotificationSettings : InitialTarget
|
||||
|
||||
@Parcelize
|
||||
data object NotificationTroubleshoot : InitialTarget
|
||||
}
|
||||
|
||||
data class Params(val initialElement: InitialTarget) : NodeInputs
|
||||
|
|
|
|||
|
|
@ -51,4 +51,5 @@ class DefaultPreferencesEntryPoint @Inject constructor() : PreferencesEntryPoint
|
|||
internal fun PreferencesEntryPoint.InitialTarget.toNavTarget() = when (this) {
|
||||
is PreferencesEntryPoint.InitialTarget.Root -> PreferencesFlowNode.NavTarget.Root
|
||||
is PreferencesEntryPoint.InitialTarget.NotificationSettings -> PreferencesFlowNode.NavTarget.NotificationSettings
|
||||
PreferencesEntryPoint.InitialTarget.NotificationTroubleshoot -> PreferencesFlowNode.NavTarget.TroubleshootNotifications
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import io.element.android.features.preferences.impl.root.PreferencesRootNode
|
|||
import io.element.android.features.preferences.impl.user.editprofile.EditUserProfileNode
|
||||
import io.element.android.libraries.architecture.BackstackView
|
||||
import io.element.android.libraries.architecture.BaseFlowNode
|
||||
import io.element.android.libraries.architecture.appyx.canPop
|
||||
import io.element.android.libraries.architecture.createNode
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
|
|
@ -190,7 +191,11 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
notificationTroubleShootEntryPoint.nodeBuilder(this, buildContext)
|
||||
.callback(object : NotificationTroubleShootEntryPoint.Callback {
|
||||
override fun onDone() {
|
||||
backstack.pop()
|
||||
if (backstack.canPop()) {
|
||||
backstack.pop()
|
||||
} else {
|
||||
navigateUp()
|
||||
}
|
||||
}
|
||||
})
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
|||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.push.api.PushService
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import javax.inject.Inject
|
||||
|
|
@ -47,6 +48,7 @@ class DefaultClearCacheUseCase @Inject constructor(
|
|||
private val okHttpClient: Provider<OkHttpClient>,
|
||||
private val ftueService: FtueService,
|
||||
private val migrationScreenStore: MigrationScreenStore,
|
||||
private val pushService: PushService,
|
||||
) : ClearCacheUseCase {
|
||||
override suspend fun invoke() = withContext(coroutineDispatchers.io) {
|
||||
// Clear Matrix cache
|
||||
|
|
@ -64,6 +66,8 @@ class DefaultClearCacheUseCase @Inject constructor(
|
|||
ftueService.reset()
|
||||
// Clear migration screen store
|
||||
migrationScreenStore.reset()
|
||||
// Ensure any error will be displayed again
|
||||
pushService.setIgnoreRegistrationError(matrixClient.sessionId, false)
|
||||
// Ensure the app is restarted
|
||||
defaultCacheService.onClearedCache(matrixClient.sessionId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,13 +329,11 @@ class NotificationSettingsPresenterTest {
|
|||
val pushProvider1 = FakePushProvider(
|
||||
index = 0,
|
||||
name = "aFakePushProvider0",
|
||||
isAvailable = true,
|
||||
distributors = listOf(Distributor("aDistributorValue0", "aDistributorName0")),
|
||||
)
|
||||
val pushProvider2 = FakePushProvider(
|
||||
index = 1,
|
||||
name = "aFakePushProvider1",
|
||||
isAvailable = true,
|
||||
distributors = listOf(Distributor("aDistributorValue1", "aDistributorName1")),
|
||||
)
|
||||
return FakePushService(
|
||||
|
|
|
|||
|
|
@ -22,8 +22,11 @@ import com.google.common.truth.Truth.assertThat
|
|||
import io.element.android.features.ftue.test.FakeFtueService
|
||||
import io.element.android.features.preferences.impl.DefaultCacheService
|
||||
import io.element.android.features.roomlist.impl.migration.InMemoryMigrationScreenStore
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||
import io.element.android.libraries.push.test.FakePushService
|
||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import io.element.android.tests.testutils.lambda.value
|
||||
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import okhttp3.OkHttpClient
|
||||
|
|
@ -48,6 +51,10 @@ class DefaultClearCacheUseCaseTest {
|
|||
val migrationScreenStore = InMemoryMigrationScreenStore(
|
||||
resetLambda = resetMigrationLambda,
|
||||
)
|
||||
val setIgnoreRegistrationErrorLambda = lambdaRecorder<SessionId, Boolean, Unit> { _, _ -> }
|
||||
val pushService = FakePushService(
|
||||
setIgnoreRegistrationErrorLambda = setIgnoreRegistrationErrorLambda
|
||||
)
|
||||
val sut = DefaultClearCacheUseCase(
|
||||
context = InstrumentationRegistry.getInstrumentation().context,
|
||||
matrixClient = matrixClient,
|
||||
|
|
@ -55,13 +62,16 @@ class DefaultClearCacheUseCaseTest {
|
|||
defaultCacheService = defaultCacheService,
|
||||
okHttpClient = { OkHttpClient.Builder().build() },
|
||||
ftueService = ftueService,
|
||||
migrationScreenStore = migrationScreenStore
|
||||
migrationScreenStore = migrationScreenStore,
|
||||
pushService = pushService,
|
||||
)
|
||||
defaultCacheService.clearedCacheEventFlow.test {
|
||||
sut.invoke()
|
||||
clearCacheLambda.assertions().isCalledOnce()
|
||||
resetFtueLambda.assertions().isCalledOnce()
|
||||
resetMigrationLambda.assertions().isCalledOnce()
|
||||
setIgnoreRegistrationErrorLambda.assertions().isCalledOnce()
|
||||
.with(value(matrixClient.sessionId), value(false))
|
||||
assertThat(awaitItem()).isEqualTo(matrixClient.sessionId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue