Commit 961f3bcd authored by Benoit Marty's avatar Benoit Marty
Browse files

More cleanup and split into several files

parent 2acfb294
......@@ -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 -> {
......
......@@ -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
}
......
/*
* 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()
}
......@@ -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<SpacePeopleSharedAction>()
/*
* 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()
}
/*
* 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()
}
......@@ -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<String> = 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
}
......
/*
* 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<String> = Uninitialized
) : MvRxState {
constructor(args: RoomProfileArgs) : this(
spaceId = args.roomId
)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment