sendAgain method
Try to send this event again. Only works with events of status -1.
If this is a file event and the file was not uploaded yet and the file is
not found in the cache locally, this throws a
FileNoLongerInCacheException.
Implementation
Future<String?> sendAgain({String? txid}) async {
if (!status.isError) return null;
// Retry sending a file:
if ({
MessageTypes.Image,
MessageTypes.Video,
MessageTypes.Audio,
MessageTypes.File,
}.contains(messageType)) {
final file = await _getCachedFile();
final thumbnail = await _getCachedFile(getThumbnail: true);
if (file == null) throw FileNoLongerInCacheException();
final credentials = FileSendRequestCredentials.fromJson(unsigned ?? {});
final inReplyTo = credentials.inReplyTo == null
? null
: await room.getEventById(credentials.inReplyTo!);
return await room.sendFileEvent(
file,
txid: txid ?? transactionId,
thumbnail: thumbnail as MatrixImageFile?,
inReplyTo: inReplyTo,
editEventId: credentials.editEventId,
shrinkImageMaxDimension: credentials.shrinkImageMaxDimension,
extraContent: credentials.extraContent,
);
}
// we do not remove the event here. It will automatically be updated
// in the `sendEvent` method to transition -1 -> 0 -> 1 -> 2
return await room.sendEvent(
content,
txid: txid ?? transactionId ?? eventId,
);
}