(
messageMap: { [messageId: string]: any },
idMap: Map<string, string>
)
| 79 | * 使用ID映射复制消息映射对象 |
| 80 | */ |
| 81 | export const copyMessageMapWithIdMap = ( |
| 82 | messageMap: { [messageId: string]: any }, |
| 83 | idMap: Map<string, string> |
| 84 | ): { [messageId: string]: any } => { |
| 85 | const newMessageMap: { [messageId: string]: any } = {} |
| 86 | |
| 87 | Object.entries(messageMap).forEach(([oldId, msg]) => { |
| 88 | const newId = idMap.get(oldId)! |
| 89 | newMessageMap[newId] = { |
| 90 | ...msg, |
| 91 | id: newId, |
| 92 | parentId: msg.parentId ? idMap.get(msg.parentId) : undefined, |
| 93 | replies: msg.replies?.map((replyId: string) => idMap.get(replyId)).filter(Boolean) || [], |
| 94 | children: msg.children?.map((childId: string) => idMap.get(childId)).filter(Boolean) || [], |
| 95 | branchIndex: msg.branchIndex, |
| 96 | isStreaming: false |
| 97 | } |
| 98 | }) |
| 99 | |
| 100 | return newMessageMap |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * 使用ID映射更新路径数组 |
nothing calls this directly
no outgoing calls
no test coverage detected