Merge branch 'develop'

This commit is contained in:
Salvatore Giordano
2021-12-09 16:12:07 +01:00
11 changed files with 43 additions and 44 deletions
-12
View File
@@ -154,18 +154,6 @@ dart_code_metrics:
# Dart Specific # Dart Specific
- binary-expression-operand-order - binary-expression-operand-order
- double-literal-format - double-literal-format
- prefer-match-file-name:
exclude:
- packages/*/test/**
- packages/*/example/**
- packages/**/util/**
- packages/**/utils.dart
- packages/stream_chat/lib/src/client/client.dart
- packages/stream_chat/lib/src/core/api/responses.dart
- packages/stream_chat/lib/src/core/api/requests.dart
- packages/stream_chat/lib/src/core/platform_detector/**
- packages/stream_chat_persistence/lib/src/db/shared/**
- packages/stream_chat_localizations/lib/src/stream_chat_localizations.dart
- no-boolean-literal-compare - no-boolean-literal-compare
- no-equal-then-else - no-equal-then-else
- no-empty-block: - no-empty-block:
+3 -2
View File
@@ -1,9 +1,10 @@
## Upcoming ## 3.3.1
🐞 Fixed 🐞 Fixed
- [[#799]](https://github.com/GetStream/stream-chat-flutter/issues/799) Fixed `totalUnreadCount` is not updating when - [[#799]](https://github.com/GetStream/stream-chat-flutter/issues/799) Fixed `totalUnreadCount` is not updating when
app is resumed from background mode app is resumed from background mode.
- Fix retry mechanism failing in some cases.
## 3.3.0 ## 3.3.0
@@ -1698,7 +1698,7 @@ class ChannelClientState {
} }
_channelState = _channelState.copyWith( _channelState = _channelState.copyWith(
messages: newMessages, messages: newMessages..sort(_sortByCreatedAt),
channel: _channelState.channel?.copyWith( channel: _channelState.channel?.copyWith(
lastMessageAt: message.createdAt, lastMessageAt: message.createdAt,
), ),
@@ -71,14 +71,15 @@ class RetryQueue {
/// Add a list of messages /// Add a list of messages
void add(List<Message> messages) { void add(List<Message> messages) {
if (messages.isEmpty) return; if (messages.isEmpty) return;
if (_messageQueue.containsAllMessage(messages)) return; if (!_messageQueue.containsAllMessage(messages)) {
logger?.info('Adding ${messages.length} messages');
final messageList = _messageQueue.toList();
// we should not add message if already available in the queue
_messageQueue.addAll(messages.where(
(it) => !messageList.any((m) => m.id == it.id),
));
}
logger?.info('Adding ${messages.length} messages');
final messageList = _messageQueue.toList();
// we should not add message if already available in the queue
_messageQueue.addAll(messages.where(
(it) => !messageList.any((m) => m.id == it.id),
));
_startRetrying(); _startRetrying();
} }
@@ -90,17 +91,21 @@ class RetryQueue {
while (_messageQueue.isNotEmpty) { while (_messageQueue.isNotEmpty) {
logger?.info('${_messageQueue.length} messages remaining in the queue'); logger?.info('${_messageQueue.length} messages remaining in the queue');
final message = _messageQueue.first; final message = _messageQueue.first;
await _runAndRetry(message); final succeeded = await _runAndRetry(message);
if (!succeeded) {
_messageQueue.toList().forEach(_sendFailedEvent);
break;
}
} }
_isRetrying = false; _isRetrying = false;
} }
Future<void> _runAndRetry(Message message) async { Future<bool> _runAndRetry(Message message) async {
var attempt = 1; var attempt = 1;
final maxAttempt = _retryPolicy.maxRetryAttempts; final maxAttempt = _retryPolicy.maxRetryAttempts;
// early return in case maxAttempt is less than 0 // early return in case maxAttempt is less than 0
if (attempt > maxAttempt) return; if (attempt > maxAttempt) return false;
// ignore: literal_only_boolean_expressions // ignore: literal_only_boolean_expressions
while (true) { while (true) {
@@ -109,8 +114,12 @@ class RetryQueue {
await _retryMessage(message); await _retryMessage(message);
logger?.info('Message (${message.id}) sent successfully'); logger?.info('Message (${message.id}) sent successfully');
_messageQueue.removeMessage(message); _messageQueue.removeMessage(message);
break; return true;
} on StreamChatError catch (e) { } catch (e) {
if (e is! StreamChatNetworkError || !e.isRetriable) {
_messageQueue.removeMessage(message);
return true;
}
// retry logic // retry logic
final maxAttempt = _retryPolicy.maxRetryAttempts; final maxAttempt = _retryPolicy.maxRetryAttempts;
if (attempt < maxAttempt) { if (attempt < maxAttempt) {
@@ -143,16 +152,9 @@ class RetryQueue {
_sendFailedEvent(message); _sendFailedEvent(message);
break; break;
} }
} catch (e) {
logger?.info(
'API call failed due to unknown error (attempt $attempt). '
'Giving up for now, will retry when connection recovers. '
'Error was $e',
);
_sendFailedEvent(message);
break;
} }
} }
return false;
} }
void _sendFailedEvent(Message message) { void _sendFailedEvent(Message message) {
+1 -1
View File
@@ -3,4 +3,4 @@ import 'package:stream_chat/src/client/client.dart';
/// Current package version /// Current package version
/// Used in [StreamChatClient] to build the `x-stream-client` header /// Used in [StreamChatClient] to build the `x-stream-client` header
// ignore: constant_identifier_names // ignore: constant_identifier_names
const PACKAGE_VERSION = '3.3.0'; const PACKAGE_VERSION = '3.3.1';
+1 -1
View File
@@ -1,7 +1,7 @@
name: stream_chat name: stream_chat
homepage: https://getstream.io/ homepage: https://getstream.io/
description: The official Dart client for Stream Chat, a service for building chat applications. description: The official Dart client for Stream Chat, a service for building chat applications.
version: 3.3.0 version: 3.3.1
repository: https://github.com/GetStream/stream-chat-flutter repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -1,3 +1,7 @@
## 3.3.2
- Updated `stream_chat_flutter_core` dependency to [`3.3.1`](https://pub.dev/packages/stream_chat_flutter_core/changelog).
## 3.3.1 ## 3.3.1
✅ Added ✅ Added
@@ -832,8 +832,8 @@ class _MessageWidgetState extends State<MessageWidget>
), ),
if (isFailedState) if (isFailedState)
Positioned( Positioned(
left: widget.reverse ? 0 : null, right: widget.reverse ? 0 : null,
right: widget.reverse ? null : 0, left: widget.reverse ? null : 0,
bottom: showBottomRow ? 18 : -2, bottom: showBottomRow ? 18 : -2,
child: StreamSvgIcon.error(size: 20), child: StreamSvgIcon.error(size: 20),
), ),
+2 -2
View File
@@ -1,7 +1,7 @@
name: stream_chat_flutter name: stream_chat_flutter
homepage: https://github.com/GetStream/stream-chat-flutter homepage: https://github.com/GetStream/stream-chat-flutter
description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
version: 3.3.1 version: 3.3.2
repository: https://github.com/GetStream/stream-chat-flutter repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -36,7 +36,7 @@ dependencies:
rxdart: ^0.27.0 rxdart: ^0.27.0
share_plus: ^3.0.4 share_plus: ^3.0.4
shimmer: ^2.0.0 shimmer: ^2.0.0
stream_chat_flutter_core: ^3.3.0 stream_chat_flutter_core: ^3.3.1
substring_highlight: ^1.0.26 substring_highlight: ^1.0.26
synchronized: ^3.0.0 synchronized: ^3.0.0
url_launcher: ^6.0.3 url_launcher: ^6.0.3
@@ -1,3 +1,7 @@
## 3.3.1
- Updated `stream_chat` dependency to [`3.3.1`](https://pub.dev/packages/stream_chat/changelog).
## 3.3.0 ## 3.3.0
- Updated `stream_chat` dependency to [`3.3.0`](https://pub.dev/packages/stream_chat/changelog). - Updated `stream_chat` dependency to [`3.3.0`](https://pub.dev/packages/stream_chat/changelog).
@@ -1,7 +1,7 @@
name: stream_chat_flutter_core name: stream_chat_flutter_core
homepage: https://github.com/GetStream/stream-chat-flutter homepage: https://github.com/GetStream/stream-chat-flutter
description: Stream Chat official Flutter SDK Core. Build your own chat experience using Dart and Flutter. description: Stream Chat official Flutter SDK Core. Build your own chat experience using Dart and Flutter.
version: 3.3.0 version: 3.3.1
repository: https://github.com/GetStream/stream-chat-flutter repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -11,12 +11,12 @@ environment:
dependencies: dependencies:
collection: ^1.15.0 collection: ^1.15.0
connectivity_plus: ^2.0.2 connectivity_plus: ^2.1.0
flutter: flutter:
sdk: flutter sdk: flutter
meta: ^1.3.0 meta: ^1.3.0
rxdart: ^0.27.0 rxdart: ^0.27.0
stream_chat: ^3.3.0 stream_chat: ^3.3.1
dev_dependencies: dev_dependencies:
dart_code_metrics: ^4.4.0 dart_code_metrics: ^4.4.0