-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8735 from shamim-emon/fix-issue-8709
Fixes New menu forgets its "Hide accounts" setting
- Loading branch information
Showing
23 changed files
with
267 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
.../src/main/kotlin/app/k9mail/feature/navigation/drawer/NavigationDrawerExternalContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package app.k9mail.feature.navigation.drawer | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface NavigationDrawerExternalContract { | ||
|
||
data class DrawerConfig( | ||
val showUnifiedFolders: Boolean, | ||
val showStarredCount: Boolean, | ||
val showAccountSelector: Boolean, | ||
) | ||
|
||
fun interface DrawerConfigLoader { | ||
fun loadDrawerConfig(): DrawerConfig | ||
fun loadDrawerConfigFlow(): Flow<DrawerConfig> | ||
} | ||
|
||
fun interface DrawerConfigWriter { | ||
fun writeDrawerConfig(drawerConfig: DrawerConfig) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...r/src/main/kotlin/app/k9mail/feature/navigation/drawer/domain/usecase/SaveDrawerConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package app.k9mail.feature.navigation.drawer.domain.usecase | ||
|
||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract | ||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfigWriter | ||
import app.k9mail.feature.navigation.drawer.domain.DomainContract.UseCase | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
|
||
internal class SaveDrawerConfig( | ||
private val drawerConfigWriter: DrawerConfigWriter, | ||
) : UseCase.SaveDrawerConfig { | ||
override fun invoke(drawerConfig: NavigationDrawerExternalContract.DrawerConfig): Flow<Unit> { | ||
return flow { | ||
emit(drawerConfigWriter.writeDrawerConfig(drawerConfig)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
...rc/test/kotlin/app/k9mail/feature/navigation/drawer/domain/usecase/GetDrawerConfigTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package app.k9mail.feature.navigation.drawer.domain.usecase | ||
|
||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfig | ||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfigLoader | ||
import assertk.assertThat | ||
import assertk.assertions.isEqualTo | ||
import kotlin.test.Test | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.flowOf | ||
import kotlinx.coroutines.test.runTest | ||
import org.mockito.Mockito.mock | ||
import org.mockito.kotlin.whenever | ||
|
||
internal class GetDrawerConfigTest { | ||
|
||
@Test | ||
fun `should get drawer config`() = runTest { | ||
val configProver: DrawerConfigLoader = mock() | ||
val drawerConfig = DrawerConfig( | ||
showUnifiedFolders = true, | ||
showStarredCount = true, | ||
showAccountSelector = true, | ||
) | ||
|
||
val testSubject = GetDrawerConfig( | ||
configProver = { drawerConfig }, | ||
) | ||
val testSubject = GetDrawerConfig(configProver = configProver) | ||
whenever(configProver.loadDrawerConfigFlow()).thenReturn(flowOf(drawerConfig)) | ||
|
||
val result = testSubject().first() | ||
|
||
assertThat(result).isEqualTo( | ||
DrawerConfig( | ||
showUnifiedFolders = true, | ||
showStarredCount = true, | ||
), | ||
) | ||
assertThat(result).isEqualTo(drawerConfig) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.