Merge branch 'develop' into message-input-controller

This commit is contained in:
Deven Joshi
2021-12-03 14:53:33 +05:30
committed by GitHub
8 changed files with 46 additions and 30 deletions
@@ -3,6 +3,7 @@ name: stream_flutter_workflow
env: env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
flutter_version: "2.5.1" flutter_version: "2.5.1"
melos_version: "1.0.0-dev.10"
on: on:
pull_request: pull_request:
@@ -31,7 +32,7 @@ jobs:
flutter-version: ${{ env.flutter_version }} flutter-version: ${{ env.flutter_version }}
- name: "Install Tools" - name: "Install Tools"
run: | run: |
flutter pub global activate melos 1.0.0-dev.10 flutter pub global activate melos ${{ env.melos_version }}
- name: "Bootstrap Workspace" - name: "Bootstrap Workspace"
run: melos bootstrap run: melos bootstrap
- name: "Dart Analyze" - name: "Dart Analyze"
@@ -60,7 +61,8 @@ jobs:
with: with:
flutter-version: ${{ env.flutter_version }} flutter-version: ${{ env.flutter_version }}
- name: "Install Tools" - name: "Install Tools"
run: flutter pub global activate melos run: |
flutter pub global activate melos ${{ env.melos_version }}
- name: "Bootstrap Workspace" - name: "Bootstrap Workspace"
run: melos bootstrap run: melos bootstrap
- name: "Melos Format" - name: "Melos Format"
@@ -71,7 +73,7 @@ jobs:
test: test:
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 15 timeout-minutes: 20
steps: steps:
- name: "Git Checkout" - name: "Git Checkout"
uses: actions/checkout@v2 uses: actions/checkout@v2
@@ -88,7 +90,7 @@ jobs:
flutter-version: ${{ env.flutter_version }} flutter-version: ${{ env.flutter_version }}
- name: "Install Tools" - name: "Install Tools"
run: | run: |
flutter pub global activate melos flutter pub global activate melos ${{ env.melos_version }}
pub global activate remove_from_coverage pub global activate remove_from_coverage
- name: "Bootstrap Workspace" - name: "Bootstrap Workspace"
run: melos bootstrap run: melos bootstrap
+7
View File
@@ -1,3 +1,10 @@
## Upcoming
🐞 Fixed
- [[#799]](https://github.com/GetStream/stream-chat-flutter/issues/799) Fixed `totalUnreadCount` is not updating when
app is resumed from background mode
## 3.3.0 ## 3.3.0
✅ Added ✅ Added
@@ -1466,8 +1466,6 @@ class ChannelClientState {
_listenMemberRemoved(); _listenMemberRemoved();
_computeUnread();
_startCleaning(); _startCleaning();
_startCleaningPinnedMessages(); _startCleaningPinnedMessages();
@@ -1490,15 +1488,6 @@ class ChannelClientState {
final _subscriptions = <StreamSubscription>[]; final _subscriptions = <StreamSubscription>[];
void _computeUnread() {
final userRead = channelState.read.firstWhereOrNull(
(r) => r.user.id == _channel._client.state.currentUser?.id,
);
if (userRead != null && userRead.unreadMessages > 0) {
unreadCount = userRead.unreadMessages;
}
}
void _checkExpiredAttachmentMessages(ChannelState channelState) async { void _checkExpiredAttachmentMessages(ChannelState channelState) async {
final expiredAttachmentMessagesId = channelState.messages final expiredAttachmentMessagesId = channelState.messages
.where((m) => .where((m) =>
@@ -1850,15 +1839,34 @@ class ChannelClientState {
/// Channel read list as a stream. /// Channel read list as a stream.
Stream<List<Read>> get readStream => channelStateStream.map((cs) => cs.read); Stream<List<Read>> get readStream => channelStateStream.map((cs) => cs.read);
final BehaviorSubject<int> _unreadCountController = BehaviorSubject.seeded(0); bool _isCurrentUserRead(Read read) =>
read.user.id == _channel._client.state.currentUser!.id;
set unreadCount(int value) => _unreadCountController.add(value); /// Channel read for the logged in user.
Read? get currentUserRead => read.firstWhereOrNull(_isCurrentUserRead);
/// Channel read for the logged in user as a stream.
Stream<Read?> get currentUserReadStream =>
readStream.map((read) => read.firstWhereOrNull(_isCurrentUserRead));
/// Unread count getter as a stream. /// Unread count getter as a stream.
Stream<int> get unreadCountStream => _unreadCountController.stream.distinct(); Stream<int> get unreadCountStream =>
currentUserReadStream.map((read) => read?.unreadMessages ?? 0);
/// Unread count getter. /// Unread count getter.
int get unreadCount => _unreadCountController.value; int get unreadCount => currentUserRead?.unreadMessages ?? 0;
/// Setter for unread count.
set unreadCount(int count) {
final reads = [..._channelState.read];
final currentUserReadIndex = reads.indexWhere(_isCurrentUserRead);
if (currentUserReadIndex < 0) return;
reads[currentUserReadIndex] =
reads[currentUserReadIndex].copyWith(unreadMessages: count);
_channelState = _channelState.copyWith(read: reads);
}
bool _countMessageAsUnread(Message message) { bool _countMessageAsUnread(Message message) {
final userId = _channel.client.state.currentUser?.id; final userId = _channel.client.state.currentUser?.id;
@@ -2118,7 +2126,6 @@ class ChannelClientState {
/// Call this method to dispose this object. /// Call this method to dispose this object.
void dispose() { void dispose() {
_debouncedUpdatePersistenceChannelState.cancel(); _debouncedUpdatePersistenceChannelState.cancel();
_unreadCountController.close();
_retryQueue.dispose(); _retryQueue.dispose();
_subscriptions.forEach((s) => s.cancel()); _subscriptions.forEach((s) => s.cancel());
_channelStateController.close(); _channelStateController.close();
@@ -395,6 +395,9 @@ class StreamChatClient {
} }
void _handleHealthCheckEvent(Event event) { void _handleHealthCheckEvent(Event event) {
final user = event.me;
if (user != null) state.currentUser = user;
final connectionId = event.connectionId; final connectionId = event.connectionId;
if (connectionId != null) { if (connectionId != null) {
_connectionIdManager.setConnectionId(connectionId); _connectionIdManager.setConnectionId(connectionId);
+1 -1
View File
@@ -6,7 +6,7 @@
- `MessageInput` now works with a `MessageInputController` instead of a `TextEditingController` - `MessageInput` now works with a `MessageInputController` instead of a `TextEditingController`
## 3.3.0 ## 3.3.1
✅ Added ✅ Added
+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.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
@@ -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.2.0 stream_chat_flutter_core: ^3.3.0
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
@@ -157,10 +157,7 @@ class ChannelListCoreState extends State<ChannelListCore> {
presence: widget.presence, presence: widget.presence,
memberLimit: widget.memberLimit, memberLimit: widget.memberLimit,
messageLimit: widget.messageLimit, messageLimit: widget.messageLimit,
paginationParams: PaginationParams( paginationParams: PaginationParams(limit: widget.limit, offset: 0),
limit: widget.limit,
offset: 0,
),
); );
/// Fetches more channels with updated pagination and updates the widget /// Fetches more channels with updated pagination and updates the widget
@@ -9,7 +9,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'mocks.dart'; import 'mocks.dart';
void main() { void main() {
const pagination = PaginationParams(limit: 3); const pagination = PaginationParams(limit: 3, offset: 0);
List<Channel> _generateChannels( List<Channel> _generateChannels(
StreamChatClient client, { StreamChatClient client, {
@@ -476,7 +476,7 @@ void main() {
_stateSetter?.call(() => limit = 6); _stateSetter?.call(() => limit = 6);
final updatedChannels = _generateChannels(mockClient, count: limit); final updatedChannels = _generateChannels(mockClient, count: limit);
final updatedPagination = PaginationParams(limit: limit); final updatedPagination = PaginationParams(limit: limit, offset: 0);
when(() => mockClient.queryChannels( when(() => mockClient.queryChannels(
filter: any(named: 'filter'), filter: any(named: 'filter'),
sort: any(named: 'sort'), sort: any(named: 'sort'),