MCPcopy Create free account
hub / github.com/experdot/pointer / createIdMapping

Function createIdMapping

src/renderer/src/stores/pagesStore.ts:1053–1073  ·  view source on GitHub ↗
(messages?: any[], messageMap?: { [messageId: string]: any })

Source from the content-addressed store, hash-verified

1051
1052 // 创建统一的ID映射表
1053 const createIdMapping = (messages?: any[], messageMap?: { [messageId: string]: any }) => {
1054 const idMap = new Map<string, string>()
1055
1056 // 为messages数组中的每个消息生成新ID
1057 if (messages) {
1058 messages.forEach((msg) => {
1059 idMap.set(msg.id, uuidv4())
1060 })
1061 }
1062
1063 // 为messageMap中可能存在但不在messages数组中的消息生成新ID
1064 if (messageMap) {
1065 Object.keys(messageMap).forEach((oldId) => {
1066 if (!idMap.has(oldId)) {
1067 idMap.set(oldId, uuidv4())
1068 }
1069 })
1070 }
1071
1072 return idMap
1073 }
1074
1075 // 创建统一的ID映射
1076 const idMap = createIdMapping(originalPage.messages, originalPage.messageMap)

Callers 1

pagesStore.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected