()
| 183 | }; |
| 184 | |
| 185 | const sendImage = async () => { |
| 186 | if (!image) { |
| 187 | return; |
| 188 | } |
| 189 | const blob = await getBlob(image); |
| 190 | const { key } = await Storage.put(`${uuidv4()}.png`, blob, { |
| 191 | progressCallback, |
| 192 | }); |
| 193 | |
| 194 | // send message |
| 195 | const user = await Auth.currentAuthenticatedUser(); |
| 196 | const newMessage = await DataStore.save( |
| 197 | new Message({ |
| 198 | content: message, |
| 199 | image: key, |
| 200 | userID: user.attributes.sub, |
| 201 | chatroomID: chatRoom.id, |
| 202 | replyToMessageID: messageReplyTo?.id, |
| 203 | }) |
| 204 | ); |
| 205 | |
| 206 | updateLastMessage(newMessage); |
| 207 | |
| 208 | resetFields(); |
| 209 | }; |
| 210 | |
| 211 | const getBlob = async (uri: string) => { |
| 212 | const respone = await fetch(uri); |
no test coverage detected