Post cherry pick fix
This commit is contained in:
parent
e4c8c88cee
commit
fbdbfb6be2
|
@ -28,6 +28,8 @@ import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import im.vector.app.AppStateHandler
|
||||||
|
import im.vector.app.AppStateHandlerImpl
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.EmojiCompatWrapper
|
import im.vector.app.EmojiCompatWrapper
|
||||||
import im.vector.app.EmojiSpanify
|
import im.vector.app.EmojiSpanify
|
||||||
|
@ -108,6 +110,9 @@ abstract class VectorBindModule {
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindSystemSettingsProvide(provider: AndroidSystemSettingsProvider): SystemSettingsProvider
|
abstract fun bindSystemSettingsProvide(provider: AndroidSystemSettingsProvider): SystemSettingsProvider
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
abstract fun bindAppStateHandler(appStateHandlerImpl: AppStateHandlerImpl): AppStateHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
|
|
|
@ -109,8 +109,8 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
combine(
|
combine(
|
||||||
appStateHandler.selectedSpaceFlow.distinctUntilChanged(),
|
appStateHandler.getSelectedSpaceFlow().distinctUntilChanged(),
|
||||||
appStateHandler.selectedSpaceFlow.flatMapLatest {
|
appStateHandler.getSelectedSpaceFlow().flatMapLatest {
|
||||||
roomService.getPagedRoomSummariesLive(
|
roomService.getPagedRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = Membership.activeMemberships()
|
this.memberships = Membership.activeMemberships()
|
||||||
|
@ -161,10 +161,10 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(
|
||||||
CountInfo(
|
CountInfo(
|
||||||
homeCount = counts,
|
homeCount = counts,
|
||||||
otherCount = RoomAggregateNotificationCount(
|
otherCount = RoomAggregateNotificationCount(
|
||||||
notificationCount = rootCounts.fold(0, { acc, rs -> acc + rs.notificationCount }) +
|
notificationCount = rootCounts.fold(0) { acc, rs -> acc + rs.notificationCount } +
|
||||||
(counts.notificationCount.takeIf { selectedSpace != null } ?: 0) +
|
(counts.notificationCount.takeIf { selectedSpace != null } ?: 0) +
|
||||||
spaceInviteCount,
|
spaceInviteCount,
|
||||||
highlightCount = rootCounts.fold(0, { acc, rs -> acc + rs.highlightCount }) +
|
highlightCount = rootCounts.fold(0) { acc, rs -> acc + rs.highlightCount } +
|
||||||
(counts.highlightCount.takeIf { selectedSpace != null } ?: 0) +
|
(counts.highlightCount.takeIf { selectedSpace != null } ?: 0) +
|
||||||
spaceInviteCount
|
spaceInviteCount
|
||||||
)
|
)
|
||||||
|
|
|
@ -94,7 +94,7 @@ class RoomListSectionBuilder(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
appStateHandler.selectedSpaceFlow
|
appStateHandler.getSelectedSpaceFlow()
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.onEach { selectedSpaceOption ->
|
.onEach { selectedSpaceOption ->
|
||||||
val selectedSpace = selectedSpaceOption.orNull()
|
val selectedSpace = selectedSpaceOption.orNull()
|
||||||
|
@ -149,7 +149,7 @@ class RoomListSectionBuilder(
|
||||||
) {
|
) {
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, false)
|
it.roomTagQueryFilter = RoomTagQueryFilter(isFavorite = false, isLowPriority = false, isServerNotice = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(
|
addSection(
|
||||||
|
@ -186,7 +186,7 @@ class RoomListSectionBuilder(
|
||||||
|
|
||||||
// add suggested rooms
|
// add suggested rooms
|
||||||
val suggestedRoomsFlow = // MutableLiveData<List<SpaceChildInfo>>()
|
val suggestedRoomsFlow = // MutableLiveData<List<SpaceChildInfo>>()
|
||||||
appStateHandler.selectedSpaceFlow
|
appStateHandler.getSelectedSpaceFlow()
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.flatMapLatest { selectedSpaceOption ->
|
.flatMapLatest { selectedSpaceOption ->
|
||||||
val selectedSpace = selectedSpaceOption.orNull()
|
val selectedSpace = selectedSpaceOption.orNull()
|
||||||
|
@ -270,7 +270,7 @@ class RoomListSectionBuilder(
|
||||||
) {
|
) {
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, null)
|
it.roomTagQueryFilter = RoomTagQueryFilter(isFavorite = false, isLowPriority = false, isServerNotice = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(
|
addSection(
|
||||||
|
@ -282,7 +282,7 @@ class RoomListSectionBuilder(
|
||||||
) {
|
) {
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(false, true, null)
|
it.roomTagQueryFilter = RoomTagQueryFilter(isFavorite = false, isLowPriority = true, isServerNotice = null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ class RoomListViewModel @AssistedInject constructor(
|
||||||
observeMembershipChanges()
|
observeMembershipChanges()
|
||||||
observeLocalRooms()
|
observeLocalRooms()
|
||||||
|
|
||||||
appStateHandler.selectedSpaceFlow
|
appStateHandler.getSelectedSpaceFlow()
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.execute {
|
.execute {
|
||||||
copy(
|
copy(
|
||||||
|
@ -148,7 +148,7 @@ class RoomListViewModel @AssistedInject constructor(
|
||||||
private val roomListSectionBuilder = RoomListSectionBuilder(
|
private val roomListSectionBuilder = RoomListSectionBuilder(
|
||||||
session,
|
session,
|
||||||
stringProvider,
|
stringProvider,
|
||||||
appStateHandlerImpl,
|
appStateHandler,
|
||||||
viewModelScope,
|
viewModelScope,
|
||||||
autoAcceptInvites,
|
autoAcceptInvites,
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,8 @@ import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.features.analytics.AnalyticsTracker
|
import im.vector.app.features.analytics.AnalyticsTracker
|
||||||
import im.vector.app.features.ui.UiStateRepository
|
import im.vector.app.features.ui.UiStateRepository
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
import org.amshove.kluent.shouldBe
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
internal class AppStateHandlerTest {
|
internal class AppStateHandlerTest {
|
||||||
|
|
||||||
|
@ -35,6 +37,11 @@ internal class AppStateHandlerTest {
|
||||||
analyticsTracker,
|
analyticsTracker,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `given selected space is null, when getCurrentSpace, then return null`() {
|
||||||
|
val currentSpace = appStateHandlerImpl.getCurrentSpace()
|
||||||
|
|
||||||
|
currentSpace shouldBe null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue