fix(android): fetch session status after creation to show all participants
- Add getPartyId() method to TssRepository - Call getSessionStatus after createKeygenSession to fetch all participants including server-party-co-managed that have already auto-joined - This matches Electron's behavior of calling getSessionStatus on session page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f305a8cd97
commit
cc56b8fadf
|
|
@ -46,6 +46,11 @@ class TssRepository @Inject constructor(
|
||||||
private var messageCollectionJob: Job? = null
|
private var messageCollectionJob: Job? = null
|
||||||
private var sessionEventJob: Job? = null
|
private var sessionEventJob: Job? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current party ID
|
||||||
|
*/
|
||||||
|
fun getPartyId(): String = partyId
|
||||||
|
|
||||||
// Track current message routing params for reconnection recovery
|
// Track current message routing params for reconnection recovery
|
||||||
private var currentMessageRoutingSessionId: String? = null
|
private var currentMessageRoutingSessionId: String? = null
|
||||||
private var currentMessageRoutingPartyIndex: Int? = null
|
private var currentMessageRoutingPartyIndex: Int? = null
|
||||||
|
|
|
||||||
|
|
@ -235,13 +235,35 @@ class MainViewModel @Inject constructor(
|
||||||
onSuccess = { sessionResult ->
|
onSuccess = { sessionResult ->
|
||||||
_createdInviteCode.value = sessionResult.inviteCode
|
_createdInviteCode.value = sessionResult.inviteCode
|
||||||
_currentSessionId.value = sessionResult.sessionId
|
_currentSessionId.value = sessionResult.sessionId
|
||||||
// Add self as first participant
|
|
||||||
_sessionParticipants.value = listOf(participantName)
|
|
||||||
// Store party index for later use
|
// Store party index for later use
|
||||||
_currentRound.value = 0
|
_currentRound.value = 0
|
||||||
_uiState.update { it.copy(isLoading = false) }
|
|
||||||
|
|
||||||
android.util.Log.d("MainViewModel", "Keygen session created: sessionId=${sessionResult.sessionId}, partyIndex=${sessionResult.partyIndex}")
|
android.util.Log.d("MainViewModel", "Keygen session created: sessionId=${sessionResult.sessionId}, partyIndex=${sessionResult.partyIndex}")
|
||||||
|
|
||||||
|
// Fetch current session status to get all participants (including server-party-co-managed)
|
||||||
|
// This matches Electron's behavior of calling getSessionStatus after session creation
|
||||||
|
val statusResult = repository.getSessionStatus(sessionResult.sessionId)
|
||||||
|
statusResult.fold(
|
||||||
|
onSuccess = { status ->
|
||||||
|
val participantNames = status.participants.mapIndexed { index, p ->
|
||||||
|
if (p.partyId == repository.getPartyId()) {
|
||||||
|
participantName // Use the name provided by user for self
|
||||||
|
} else {
|
||||||
|
"参与方 ${index + 1}" // Generic name for others
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_sessionParticipants.value = participantNames
|
||||||
|
android.util.Log.d("MainViewModel", "Session status fetched: ${status.participants.size} participants already joined")
|
||||||
|
android.util.Log.d("MainViewModel", " Participants: ${status.participants.map { it.partyId }}")
|
||||||
|
},
|
||||||
|
onFailure = { e ->
|
||||||
|
// Fallback to just self if status fetch fails
|
||||||
|
_sessionParticipants.value = listOf(participantName)
|
||||||
|
android.util.Log.w("MainViewModel", "Failed to fetch session status: ${e.message}, using self only")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
_uiState.update { it.copy(isLoading = false) }
|
||||||
},
|
},
|
||||||
onFailure = { e ->
|
onFailure = { e ->
|
||||||
_uiState.update { it.copy(isLoading = false, error = e.message) }
|
_uiState.update { it.copy(isLoading = false, error = e.message) }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue