({
id: messageId,
body,
}: {
id: string;
body: string;
})
| 683 | }; |
| 684 | |
| 685 | const editMessage = async ({ |
| 686 | id: messageId, |
| 687 | body, |
| 688 | }: { |
| 689 | id: string; |
| 690 | body: string; |
| 691 | }) => { |
| 692 | setThreads((threads) => { |
| 693 | return threads.map((thread) => { |
| 694 | const message = thread.messages.find( |
| 695 | ({ id }: SerializedMessage) => id === messageId |
| 696 | ); |
| 697 | if (message) { |
| 698 | return { |
| 699 | ...thread, |
| 700 | messages: thread.messages.map((message: SerializedMessage) => { |
| 701 | if (message.id === messageId) { |
| 702 | return { |
| 703 | ...message, |
| 704 | body, |
| 705 | }; |
| 706 | } |
| 707 | return message; |
| 708 | }), |
| 709 | }; |
| 710 | } |
| 711 | return thread; |
| 712 | }); |
| 713 | }); |
| 714 | return api |
| 715 | .updateMessage({ |
| 716 | accountId: settings.communityId, |
| 717 | id: messageId, |
| 718 | body, |
| 719 | }) |
| 720 | .catch((_) => { |
| 721 | Toast.error('Failed to edit the message.'); |
| 722 | }); |
| 723 | }; |
| 724 | |
| 725 | function onThreadMessage( |
| 726 | threadId: string, |
nothing calls this directly
no test coverage detected