()
| 253 | } |
| 254 | |
| 255 | const sendAudio = async () => { |
| 256 | if (!soundURI) { |
| 257 | return; |
| 258 | } |
| 259 | const uriParts = soundURI.split("."); |
| 260 | const extenstion = uriParts[uriParts.length - 1]; |
| 261 | const blob = await getBlob(soundURI); |
| 262 | const { key } = await Storage.put(`${uuidv4()}.${extenstion}`, blob, { |
| 263 | progressCallback, |
| 264 | }); |
| 265 | |
| 266 | // send message |
| 267 | const user = await Auth.currentAuthenticatedUser(); |
| 268 | const newMessage = await DataStore.save( |
| 269 | new Message({ |
| 270 | content: message, |
| 271 | audio: key, |
| 272 | userID: user.attributes.sub, |
| 273 | chatroomID: chatRoom.id, |
| 274 | status: "SENT", |
| 275 | replyToMessageID: messageReplyTo?.id, |
| 276 | }) |
| 277 | ); |
| 278 | |
| 279 | updateLastMessage(newMessage); |
| 280 | |
| 281 | resetFields(); |
| 282 | }; |
| 283 | |
| 284 | return ( |
| 285 | <KeyboardAvoidingView |
no test coverage detected