diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleFragment.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleFragment.kt index 7f5369a6ec..e6a84a37cf 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleFragment.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleFragment.kt @@ -71,7 +71,7 @@ class SpacePeopleFragment @Inject constructor( return roomMemberModelFactory.create(initialState) } - override fun invalidate() = withState(viewModel, membersViewModel) { baseState, memberListState -> + override fun invalidate() = withState(membersViewModel) { memberListState -> views.appBarTitle.text = getString(R.string.bottom_action_people) val memberCount = (memberListState.roomSummary.invoke()?.otherMemberIds?.size ?: 0) + 1 views.appBarSpaceInfo.text = resources.getQuantityString(R.plurals.room_title_members, memberCount, memberCount) @@ -133,7 +133,7 @@ class SpacePeopleFragment @Inject constructor( private fun handleViewEvents(events: SpacePeopleViewEvents) { when (events) { - is SpacePeopleViewEvents.OpenRoom -> { + is SpacePeopleViewEvents.OpenRoom -> { sharedActionViewModel.post(SpacePeopleSharedAction.NavigateToRoom(events.roomId)) } is SpacePeopleViewEvents.InviteToSpace -> { diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleListController.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleListController.kt index fc982862a7..71be3690a1 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleListController.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleListController.kt @@ -159,7 +159,7 @@ class SpacePeopleListController @Inject constructor( private fun RoomMemberListCategories.toPowerLevelLabel(): String? { return when (this) { - RoomMemberListCategories.ADMIN -> stringProvider.getString(R.string.power_level_admin) + RoomMemberListCategories.ADMIN -> stringProvider.getString(R.string.power_level_admin) RoomMemberListCategories.MODERATOR -> stringProvider.getString(R.string.power_level_moderator) else -> null } diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedAction.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedAction.kt new file mode 100644 index 0000000000..201196c865 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedAction.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.spaces.people + +import im.vector.app.core.platform.VectorSharedAction + +sealed class SpacePeopleSharedAction : VectorSharedAction { + object Dismiss : SpacePeopleSharedAction() + object ShowModalLoading : SpacePeopleSharedAction() + object HideModalLoading : SpacePeopleSharedAction() + data class NavigateToRoom(val roomId: String) : SpacePeopleSharedAction() + data class NavigateToInvite(val spaceId: String) : SpacePeopleSharedAction() +} diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedActionViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedActionViewModel.kt index 649f241bf9..ace942cd63 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedActionViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleSharedActionViewModel.kt @@ -16,16 +16,7 @@ package im.vector.app.features.spaces.people -import im.vector.app.core.platform.VectorSharedAction import im.vector.app.core.platform.VectorSharedActionViewModel import javax.inject.Inject -sealed class SpacePeopleSharedAction : VectorSharedAction { - object Dismiss : SpacePeopleSharedAction() - object ShowModalLoading : SpacePeopleSharedAction() - object HideModalLoading : SpacePeopleSharedAction() - data class NavigateToRoom(val roomId: String) : SpacePeopleSharedAction() - data class NavigateToInvite(val spaceId: String) : SpacePeopleSharedAction() -} - class SpacePeopleSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel() diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewAction.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewAction.kt new file mode 100644 index 0000000000..39d9dddc3a --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewAction.kt @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.spaces.people + +import im.vector.app.core.platform.VectorViewModelAction +import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary + +sealed class SpacePeopleViewAction : VectorViewModelAction { + data class ChatWith(val member: RoomMemberSummary) : SpacePeopleViewAction() + object InviteToSpace : SpacePeopleViewAction() +} diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewEvents.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewEvents.kt new file mode 100644 index 0000000000..e2d93668f2 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewEvents.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.spaces.people + +import im.vector.app.core.platform.VectorViewEvents + +sealed class SpacePeopleViewEvents : VectorViewEvents { + data class OpenRoom(val roomId: String) : SpacePeopleViewEvents() + data class InviteToSpace(val spaceId: String) : SpacePeopleViewEvents() +} diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt index 71c3bcdda7..13944adfc8 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt @@ -18,51 +18,25 @@ package im.vector.app.features.spaces.people import androidx.lifecycle.viewModelScope import com.airbnb.mvrx.ActivityViewModelContext -import com.airbnb.mvrx.Async import com.airbnb.mvrx.Fail import com.airbnb.mvrx.FragmentViewModelContext import com.airbnb.mvrx.Loading -import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.MvRxViewModelFactory import com.airbnb.mvrx.Success -import com.airbnb.mvrx.Uninitialized import com.airbnb.mvrx.ViewModelContext import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import im.vector.app.core.extensions.exhaustive -import im.vector.app.core.platform.VectorViewEvents import im.vector.app.core.platform.VectorViewModel -import im.vector.app.core.platform.VectorViewModelAction import im.vector.app.features.raw.wellknown.getElementWellknown import im.vector.app.features.raw.wellknown.isE2EByDefault -import im.vector.app.features.roomprofile.RoomProfileArgs import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.matrix.android.sdk.api.raw.RawService import org.matrix.android.sdk.api.session.Session -import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams -data class SpacePeopleViewState( - val spaceId: String, - val createAndInviteState: Async = Uninitialized -) : MvRxState { - constructor(args: RoomProfileArgs) : this( - spaceId = args.roomId - ) -} - -sealed class SpacePeopleViewAction : VectorViewModelAction { - data class ChatWith(val member: RoomMemberSummary) : SpacePeopleViewAction() - object InviteToSpace : SpacePeopleViewAction() -} - -sealed class SpacePeopleViewEvents : VectorViewEvents { - data class OpenRoom(val roomId: String) : SpacePeopleViewEvents() - data class InviteToSpace(val spaceId: String) : SpacePeopleViewEvents() -} - class SpacePeopleViewModel @AssistedInject constructor( @Assisted val initialState: SpacePeopleViewState, private val rawService: RawService, @@ -86,7 +60,7 @@ class SpacePeopleViewModel @AssistedInject constructor( override fun handle(action: SpacePeopleViewAction) { when (action) { - is SpacePeopleViewAction.ChatWith -> handleChatWith(action) + is SpacePeopleViewAction.ChatWith -> handleChatWith(action) SpacePeopleViewAction.InviteToSpace -> handleInviteToSpace() }.exhaustive } diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewState.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewState.kt new file mode 100644 index 0000000000..094145f901 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewState.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.spaces.people + +import com.airbnb.mvrx.Async +import com.airbnb.mvrx.MvRxState +import com.airbnb.mvrx.Uninitialized +import im.vector.app.features.roomprofile.RoomProfileArgs + +data class SpacePeopleViewState( + val spaceId: String, + val createAndInviteState: Async = Uninitialized +) : MvRxState { + constructor(args: RoomProfileArgs) : this( + spaceId = args.roomId + ) +}