({ id, body }: { id: string; body: string })
| 103 | }; |
| 104 | |
| 105 | const editMessage = ({ id, body }: { id: string; body: string }) => { |
| 106 | setThread((thread: SerializedThread) => { |
| 107 | return { |
| 108 | ...thread, |
| 109 | messages: thread.messages.map((message: SerializedMessage) => { |
| 110 | if (message.id === id) { |
| 111 | return { |
| 112 | ...message, |
| 113 | body, |
| 114 | }; |
| 115 | } |
| 116 | return message; |
| 117 | }), |
| 118 | }; |
| 119 | }); |
| 120 | return api |
| 121 | .updateMessage({ |
| 122 | accountId: settings.communityId, |
| 123 | id, |
| 124 | body, |
| 125 | }) |
| 126 | .catch((_) => { |
| 127 | Toast.error('Failed to update the message.'); |
| 128 | }); |
| 129 | }; |
| 130 | |
| 131 | const debouncedCreateMessage = useCallback( |
| 132 | debounce(api.createMessage, 100), |
no test coverage detected