chore: merge latest changes
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -876,6 +876,23 @@ class Channel {
|
||||
}
|
||||
}
|
||||
|
||||
/// Retry the operation on the message based on the failed state.
|
||||
///
|
||||
/// For example, if the message failed to send, it will retry sending the
|
||||
/// message and vice-versa.
|
||||
Future<Object> retryMessage(Message message) async {
|
||||
assert(message.state.isFailed, 'Message state is not failed');
|
||||
|
||||
return message.state.maybeWhen(
|
||||
failed: (state, _) => state.when(
|
||||
sendingFailed: () => sendMessage(message),
|
||||
updatingFailed: () => updateMessage(message),
|
||||
deletingFailed: (hard) => deleteMessage(message, hard: hard),
|
||||
),
|
||||
orElse: () => throw StateError('Message state is not failed'),
|
||||
);
|
||||
}
|
||||
|
||||
/// Pins provided message
|
||||
Future<UpdateMessageResponse> pinMessage(
|
||||
Message message, {
|
||||
|
||||
@@ -89,7 +89,7 @@ class RetryQueue {
|
||||
final retryPolicy = _retryPolicy;
|
||||
try {
|
||||
await backOff(
|
||||
() => _retryMessage(message),
|
||||
() => channel.retryMessage(message),
|
||||
delayFactor: retryPolicy.delayFactor,
|
||||
randomizationFactor: retryPolicy.randomizationFactor,
|
||||
maxDelay: retryPolicy.maxDelay,
|
||||
@@ -113,17 +113,6 @@ class RetryQueue {
|
||||
_isProcessing = false;
|
||||
}
|
||||
|
||||
Future<Object> _retryMessage(Message message) async {
|
||||
return message.state.maybeWhen(
|
||||
failed: (state, _) => state.when(
|
||||
sendingFailed: () => channel.sendMessage(message),
|
||||
updatingFailed: () => channel.updateMessage(message),
|
||||
deletingFailed: (hard) => channel.deleteMessage(message, hard: hard),
|
||||
),
|
||||
orElse: () => throw StateError('Message state is not failed'),
|
||||
);
|
||||
}
|
||||
|
||||
/// Whether our [_messageQueue] has messages or not.
|
||||
bool get hasMessages => _messageQueue.isNotEmpty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user