( entityText: EntityText, )
| 489 | | FarcasterUserEntity |
| 490 | | ShadowUserEntity; |
| 491 | function entityTextToObjects( |
| 492 | entityText: EntityText, |
| 493 | ): EntityTextComponentAsObject[] { |
| 494 | const objs: EntityTextComponentAsObject[] = []; |
| 495 | for (const entity of entityText) { |
| 496 | if (typeof entity === 'string') { |
| 497 | objs.push({ type: 'text', text: entity }); |
| 498 | continue; |
| 499 | } |
| 500 | objs.push(entity); |
| 501 | if ( |
| 502 | entity.type === 'thread' && |
| 503 | entity.display === 'uiName' && |
| 504 | typeof entity.uiName !== 'string' |
| 505 | ) { |
| 506 | for (const innerEntity of entity.uiName) { |
| 507 | if (typeof innerEntity === 'string' || innerEntity.type !== 'user') { |
| 508 | continue; |
| 509 | } |
| 510 | const { username } = innerEntity; |
| 511 | if (username) { |
| 512 | objs.push({ |
| 513 | type: 'shadowUser', |
| 514 | originalUsername: username, |
| 515 | username, |
| 516 | }); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | return objs; |
| 522 | } |
| 523 | function entityTextFromObjects( |
| 524 | objects: $ReadOnlyArray<EntityTextComponentAsObject>, |
| 525 | ): EntityText { |
no test coverage detected