retryMessage method
Retries a failed message.
This method attempts to re-dispatch a message that previously failed. It removes the failed message from the UI and attempts dispatch again using the original dispatch callback.
Implementation
Future retryMessage(Message message) async {
final entry = _failedMessageEntries[message.id];
if (entry == null) {
_dispatchResultController.add(MessageDispatchResult(
message: message,
isSuccess: false,
exception: Exception("Failed to dispatch message"),
));
return;
}
final failedGroup = entry.messageGroup;
if (failedGroup.messages.isEmpty) {
_dispatchResultController.add(MessageDispatchResult(
message: message,
isSuccess: false,
exception: Exception("Failed to dispatch message"),
));
return;
}
removeMessageFromGroup(failedGroup, message);
await dispatchMessage(message, onDispatch: entry.onDispatch).then((result) {
if (result.isSuccess) {
_failedMessageEntries.remove(message.id);
}
});
}