(id: string)
| 162 | const visited = new Set<string>() |
| 163 | |
| 164 | function collect(id: string): void { |
| 165 | if (visited.has(id)) return |
| 166 | visited.add(id) |
| 167 | |
| 168 | const msg = messageMap.get(id) |
| 169 | if (!msg) return |
| 170 | |
| 171 | result.push(msg) |
| 172 | |
| 173 | if (endMessageId && id === endMessageId) return |
| 174 | |
| 175 | for (const m of messages) { |
| 176 | if (m.parentMessageId === id) { |
| 177 | if (allTopicStartIds.has(m.id) && m.id !== startMessageId) { |
| 178 | continue |
| 179 | } |
| 180 | collect(m.id) |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | collect(startMessageId) |
| 186 | return result |
no test coverage detected