Post cherry pick fix

This commit is contained in:
ericdecanini 2022-07-08 11:56:00 +01:00
parent e4c8c88cee
commit fbdbfb6be2
5 changed files with 23 additions and 11 deletions

View File

@ -28,6 +28,8 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import im.vector.app.AppStateHandler
import im.vector.app.AppStateHandlerImpl
import im.vector.app.BuildConfig
import im.vector.app.EmojiCompatWrapper
import im.vector.app.EmojiSpanify
@ -108,6 +110,9 @@ abstract class VectorBindModule {
@Binds
abstract fun bindSystemSettingsProvide(provider: AndroidSystemSettingsProvider): SystemSettingsProvider
@Binds
abstract fun bindAppStateHandler(appStateHandlerImpl: AppStateHandlerImpl): AppStateHandler
}
@InstallIn(SingletonComponent::class)

View File

@ -109,8 +109,8 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(
}
combine(
appStateHandler.selectedSpaceFlow.distinctUntilChanged(),
appStateHandler.selectedSpaceFlow.flatMapLatest {
appStateHandler.getSelectedSpaceFlow().distinctUntilChanged(),
appStateHandler.getSelectedSpaceFlow().flatMapLatest {
roomService.getPagedRoomSummariesLive(
roomSummaryQueryParams {
this.memberships = Membership.activeMemberships()
@ -161,10 +161,10 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(
CountInfo(
homeCount = counts,
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) +
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) +
spaceInviteCount
)

View File

@ -94,7 +94,7 @@ class RoomListSectionBuilder(
}
}
appStateHandler.selectedSpaceFlow
appStateHandler.getSelectedSpaceFlow()
.distinctUntilChanged()
.onEach { selectedSpaceOption ->
val selectedSpace = selectedSpaceOption.orNull()
@ -149,7 +149,7 @@ class RoomListSectionBuilder(
) {
it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, false)
it.roomTagQueryFilter = RoomTagQueryFilter(isFavorite = false, isLowPriority = false, isServerNotice = false)
}
addSection(
@ -186,7 +186,7 @@ class RoomListSectionBuilder(
// add suggested rooms
val suggestedRoomsFlow = // MutableLiveData<List<SpaceChildInfo>>()
appStateHandler.selectedSpaceFlow
appStateHandler.getSelectedSpaceFlow()
.distinctUntilChanged()
.flatMapLatest { selectedSpaceOption ->
val selectedSpace = selectedSpaceOption.orNull()
@ -270,7 +270,7 @@ class RoomListSectionBuilder(
) {
it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, null)
it.roomTagQueryFilter = RoomTagQueryFilter(isFavorite = false, isLowPriority = false, isServerNotice = null)
}
addSection(
@ -282,7 +282,7 @@ class RoomListSectionBuilder(
) {
it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
it.roomTagQueryFilter = RoomTagQueryFilter(false, true, null)
it.roomTagQueryFilter = RoomTagQueryFilter(isFavorite = false, isLowPriority = true, isServerNotice = null)
}
}

View File

@ -100,7 +100,7 @@ class RoomListViewModel @AssistedInject constructor(
observeMembershipChanges()
observeLocalRooms()
appStateHandler.selectedSpaceFlow
appStateHandler.getSelectedSpaceFlow()
.distinctUntilChanged()
.execute {
copy(
@ -148,7 +148,7 @@ class RoomListViewModel @AssistedInject constructor(
private val roomListSectionBuilder = RoomListSectionBuilder(
session,
stringProvider,
appStateHandlerImpl,
appStateHandler,
viewModelScope,
autoAcceptInvites,
{

View File

@ -20,6 +20,8 @@ import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.features.analytics.AnalyticsTracker
import im.vector.app.features.ui.UiStateRepository
import io.mockk.mockk
import org.amshove.kluent.shouldBe
import org.junit.Test
internal class AppStateHandlerTest {
@ -35,6 +37,11 @@ internal class AppStateHandlerTest {
analyticsTracker,
)
@Test
fun `given selected space is null, when getCurrentSpace, then return null`() {
val currentSpace = appStateHandlerImpl.getCurrentSpace()
currentSpace shouldBe null
}
}