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(
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
onCharacter = {
|
||||
playerDetailViewModel.showCharacter(characterSheetId = it)
|
||||
scope.launch {
|
||||
playerDetailViewModel.showCharacter(characterSheetId = it)
|
||||
}
|
||||
},
|
||||
onLevelUp = {
|
||||
screen.navigateToLevelScreen(characterSheetId = it)
|
||||
|
|
@ -128,7 +130,9 @@ fun CampaignScreen(
|
|||
NpcRibbon(
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
onCharacter = {
|
||||
npcDetailViewModel.showCharacter(characterSheetId = it)
|
||||
scope.launch {
|
||||
npcDetailViewModel.showCharacter(characterSheetId = it)
|
||||
}
|
||||
},
|
||||
onLevelUp = {
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.pixelized.desktop.lwa.ui.screen.campaign.player.detail
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
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.network.NetworkRepository
|
||||
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.map
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class CharacterDetailViewModel(
|
||||
private val characterSheetRepository: CharacterSheetRepository,
|
||||
|
|
@ -65,7 +65,12 @@ class CharacterDetailViewModel(
|
|||
initialValue = empty(),
|
||||
)
|
||||
|
||||
fun showCharacter(characterSheetId: String) {
|
||||
suspend fun showCharacter(
|
||||
characterSheetId: String,
|
||||
) {
|
||||
if (characterSheetRepository.characterDetail(characterSheetId = characterSheetId) == null) {
|
||||
characterSheetRepository.updateCharacterSheet(characterSheetId = characterSheetId)
|
||||
}
|
||||
displayedCharacterId.value = characterSheetId
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ fun GMCharacterPage(
|
|||
onTag = viewModel::onTag,
|
||||
onCharacterAction = viewModel::onCharacterAction,
|
||||
onCharacterSheetDetail = { characterSheetId ->
|
||||
characterDetailViewModel.showCharacter(characterSheetId = characterSheetId)
|
||||
scope.launch {
|
||||
characterDetailViewModel.showCharacter(characterSheetId = characterSheetId)
|
||||
}
|
||||
},
|
||||
onCharacterSheetEdit = { characterSheetId ->
|
||||
scope.launch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue