Fix GM character sheet update.
This commit is contained in:
parent
3182d2b595
commit
b09a6d5184
3 changed files with 16 additions and 5 deletions
|
|
@ -104,7 +104,9 @@ fun CampaignScreen(
|
||||||
PlayerRibbon(
|
PlayerRibbon(
|
||||||
modifier = Modifier.fillMaxHeight(),
|
modifier = Modifier.fillMaxHeight(),
|
||||||
onCharacter = {
|
onCharacter = {
|
||||||
playerDetailViewModel.showCharacter(characterSheetId = it)
|
scope.launch {
|
||||||
|
playerDetailViewModel.showCharacter(characterSheetId = it)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLevelUp = {
|
onLevelUp = {
|
||||||
screen.navigateToLevelScreen(characterSheetId = it)
|
screen.navigateToLevelScreen(characterSheetId = it)
|
||||||
|
|
@ -128,7 +130,9 @@ fun CampaignScreen(
|
||||||
NpcRibbon(
|
NpcRibbon(
|
||||||
modifier = Modifier.fillMaxHeight(),
|
modifier = Modifier.fillMaxHeight(),
|
||||||
onCharacter = {
|
onCharacter = {
|
||||||
npcDetailViewModel.showCharacter(characterSheetId = it)
|
scope.launch {
|
||||||
|
npcDetailViewModel.showCharacter(characterSheetId = it)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onLevelUp = {
|
onLevelUp = {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.pixelized.desktop.lwa.ui.screen.campaign.player.detail
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.pixelized.desktop.lwa.repository.alteration.AlterationRepository
|
import com.pixelized.desktop.lwa.repository.alteration.AlterationRepository
|
||||||
import com.pixelized.desktop.lwa.repository.campaign.CampaignRepository
|
|
||||||
import com.pixelized.desktop.lwa.repository.characterSheet.CharacterSheetRepository
|
import com.pixelized.desktop.lwa.repository.characterSheet.CharacterSheetRepository
|
||||||
import com.pixelized.desktop.lwa.repository.network.NetworkRepository
|
import com.pixelized.desktop.lwa.repository.network.NetworkRepository
|
||||||
import com.pixelized.shared.lwa.protocol.websocket.CharacterSheetEvent
|
import com.pixelized.shared.lwa.protocol.websocket.CharacterSheetEvent
|
||||||
|
|
@ -13,6 +12,7 @@ import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class CharacterDetailViewModel(
|
class CharacterDetailViewModel(
|
||||||
private val characterSheetRepository: CharacterSheetRepository,
|
private val characterSheetRepository: CharacterSheetRepository,
|
||||||
|
|
@ -65,7 +65,12 @@ class CharacterDetailViewModel(
|
||||||
initialValue = empty(),
|
initialValue = empty(),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun showCharacter(characterSheetId: String) {
|
suspend fun showCharacter(
|
||||||
|
characterSheetId: String,
|
||||||
|
) {
|
||||||
|
if (characterSheetRepository.characterDetail(characterSheetId = characterSheetId) == null) {
|
||||||
|
characterSheetRepository.updateCharacterSheet(characterSheetId = characterSheetId)
|
||||||
|
}
|
||||||
displayedCharacterId.value = characterSheetId
|
displayedCharacterId.value = characterSheetId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,9 @@ fun GMCharacterPage(
|
||||||
onTag = viewModel::onTag,
|
onTag = viewModel::onTag,
|
||||||
onCharacterAction = viewModel::onCharacterAction,
|
onCharacterAction = viewModel::onCharacterAction,
|
||||||
onCharacterSheetDetail = { characterSheetId ->
|
onCharacterSheetDetail = { characterSheetId ->
|
||||||
characterDetailViewModel.showCharacter(characterSheetId = characterSheetId)
|
scope.launch {
|
||||||
|
characterDetailViewModel.showCharacter(characterSheetId = characterSheetId)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onCharacterSheetEdit = { characterSheetId ->
|
onCharacterSheetEdit = { characterSheetId ->
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue