fix(service-party-app): 保留正确的 partyIndex 不覆盖
问题: - handleSessionStart 中使用 forEach 的 index 作为 partyIndex - 这会覆盖 checkAndTriggerKeygen 已经从服务器获取的正确 partyIndex - 导致 TSS 协议使用错误的 partyIndex 修复: - 优先使用 existing.partyIndex(从服务器获取的正确值) - 只有找不到已有信息时才使用 fallback - 按 partyIndex 排序确保顺序正确 🤖 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
e72f96da10
commit
b938722ff6
|
|
@ -420,20 +420,35 @@ async function handleSessionStart(event: {
|
||||||
keygenInProgressSessionId = event.sessionId;
|
keygenInProgressSessionId = event.sessionId;
|
||||||
|
|
||||||
// 从事件中更新参与者列表(如果事件包含完整列表)
|
// 从事件中更新参与者列表(如果事件包含完整列表)
|
||||||
|
// 注意:activeKeygenSession.participants 可能已经包含正确的 partyIndex(从 checkAndTriggerKeygen 更新)
|
||||||
|
// 只有当事件来自 session_started 事件时才需要重新构建
|
||||||
if (event.selectedParties && event.selectedParties.length > 0) {
|
if (event.selectedParties && event.selectedParties.length > 0) {
|
||||||
const myPartyId = grpcClient?.getPartyId();
|
const myPartyId = grpcClient?.getPartyId();
|
||||||
const updatedParticipants: Array<{ partyId: string; partyIndex: number; name: string }> = [];
|
const updatedParticipants: Array<{ partyId: string; partyIndex: number; name: string }> = [];
|
||||||
|
|
||||||
event.selectedParties.forEach((partyId, index) => {
|
event.selectedParties.forEach((partyId) => {
|
||||||
// 查找已有的参与者信息
|
// 查找已有的参与者信息(优先使用已有的 partyIndex)
|
||||||
const existing = activeKeygenSession!.participants.find(p => p.partyId === partyId);
|
const existing = activeKeygenSession!.participants.find(p => p.partyId === partyId);
|
||||||
updatedParticipants.push({
|
if (existing) {
|
||||||
partyId: partyId,
|
// 保留已有的 partyIndex
|
||||||
partyIndex: index,
|
updatedParticipants.push({
|
||||||
name: existing?.name || (partyId === myPartyId ? '我' : `参与方 ${index + 1}`),
|
partyId: partyId,
|
||||||
});
|
partyIndex: existing.partyIndex,
|
||||||
|
name: existing.name || (partyId === myPartyId ? '我' : `参与方 ${existing.partyIndex + 1}`),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 找不到已有信息,这不应该发生
|
||||||
|
debugLog.warn('main', `Party ${partyId} not found in existing participants, using fallback index`);
|
||||||
|
updatedParticipants.push({
|
||||||
|
partyId: partyId,
|
||||||
|
partyIndex: updatedParticipants.length,
|
||||||
|
name: partyId === myPartyId ? '我' : `参与方 ${updatedParticipants.length + 1}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 按 partyIndex 排序
|
||||||
|
updatedParticipants.sort((a, b) => a.partyIndex - b.partyIndex);
|
||||||
activeKeygenSession.participants = updatedParticipants;
|
activeKeygenSession.participants = updatedParticipants;
|
||||||
|
|
||||||
// 更新自己的 partyIndex
|
// 更新自己的 partyIndex
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue