@@ -1,3 +1,7 @@
|
||||
## 1.3.1-beta
|
||||
|
||||
- Debounced frequent db calls
|
||||
|
||||
## 1.3.0-beta
|
||||
|
||||
- Save pinned messages in offline storage
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:stream_chat/src/api/retry_queue.dart';
|
||||
import 'package:stream_chat/src/debounce.dart';
|
||||
import 'package:stream_chat/src/event_type.dart';
|
||||
import 'package:stream_chat/src/models/attachment_file.dart';
|
||||
import 'package:stream_chat/src/models/channel_state.dart';
|
||||
@@ -237,9 +238,15 @@ class Channel {
|
||||
}
|
||||
|
||||
void onSendProgress(int sent, int total) {
|
||||
updateAttachment(it.copyWith(
|
||||
uploadState: UploadState.inProgress(uploaded: sent, total: total),
|
||||
));
|
||||
debounce(
|
||||
timeout: Duration(seconds: 1),
|
||||
target: updateAttachment,
|
||||
positionalArguments: [
|
||||
it.copyWith(
|
||||
uploadState: UploadState.inProgress(uploaded: sent, total: total),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final isImage = it.type == 'image';
|
||||
@@ -1441,7 +1448,7 @@ class ChannelClientState {
|
||||
|
||||
final oldIndex = newMessages.indexWhere((m) => m.id == message.id);
|
||||
if (oldIndex != -1) {
|
||||
newMessages[oldIndex] = newMessages[oldIndex].merge(message);
|
||||
newMessages[oldIndex] = message;
|
||||
} else {
|
||||
newMessages.add(message);
|
||||
}
|
||||
@@ -1685,7 +1692,11 @@ class ChannelClientState {
|
||||
|
||||
set _channelState(ChannelState v) {
|
||||
_channelStateController.add(v);
|
||||
_channel._client.chatPersistenceClient?.updateChannelState(v);
|
||||
debounce(
|
||||
timeout: Duration(milliseconds: 500),
|
||||
target: _channel._client.chatPersistenceClient?.updateChannelState,
|
||||
positionalArguments: [v],
|
||||
);
|
||||
}
|
||||
|
||||
/// The channel threads related to this channel
|
||||
|
||||
@@ -47,6 +47,7 @@ class RetryQueue {
|
||||
|
||||
/// Add a list of messages
|
||||
void add(List<Message> messages) {
|
||||
logger?.info('added ${messages.length} messages');
|
||||
final messageList = _messageQueue.toList();
|
||||
_messageQueue.addAll(messages
|
||||
.where((element) => !messageList.any((m) => m.id == element.id)));
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// Map of timeouts being debounced
|
||||
Map<Function, Timer> timeouts = {};
|
||||
|
||||
/// Runs a function avoiding calling it too many times in a [timeoutMS] window
|
||||
void debounce({
|
||||
@required Duration timeout,
|
||||
@required Function target,
|
||||
List positionalArguments,
|
||||
Map<Symbol, dynamic> namedArguments,
|
||||
}) {
|
||||
if (timeouts.containsKey(target)) {
|
||||
timeouts[target].cancel();
|
||||
}
|
||||
|
||||
final timer = Timer(timeout, () {
|
||||
Function.apply(
|
||||
target,
|
||||
positionalArguments,
|
||||
namedArguments,
|
||||
);
|
||||
});
|
||||
|
||||
timeouts[target] = timer;
|
||||
}
|
||||
@@ -2,4 +2,4 @@ import 'package:stream_chat/src/client.dart';
|
||||
|
||||
/// Current package version
|
||||
/// Used in [StreamChatClient] to build the `x-stream-client` header
|
||||
const PACKAGE_VERSION = '1.3.0-beta';
|
||||
const PACKAGE_VERSION = '1.3.1-beta';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: stream_chat
|
||||
homepage: https://getstream.io/
|
||||
description: The official Dart client for Stream Chat, a service for building chat applications.
|
||||
version: 1.3.0-beta
|
||||
version: 1.3.1-beta
|
||||
repository: https://github.com/GetStream/stream-chat-flutter
|
||||
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
## 1.3.1-beta
|
||||
|
||||
- Updated `stream_chat_core` dependency
|
||||
- Fixed minor bugs
|
||||
|
||||
## 1.3.0-beta
|
||||
|
||||
- Added `MessageInputTheme`
|
||||
@@ -5,12 +10,12 @@
|
||||
- Delete only image on imagegallery
|
||||
- Close keyboard after sending a command
|
||||
- Exposed `customAttachmentBuilders` through `MessageListView`
|
||||
- Update `stream_chat_core` dependency
|
||||
- Updated `stream_chat_core` dependency
|
||||
|
||||
## 1.2.0-beta
|
||||
|
||||
- Minor fixes
|
||||
- Update `stream_chat_core` dependency
|
||||
- Updated `stream_chat_core` dependency
|
||||
|
||||
## 1.1.1-beta
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class _ChannelFileDisplayScreenState extends State<ChannelFileDisplayScreen> {
|
||||
messageSearchBloc.search(
|
||||
filter: {
|
||||
'cid': {
|
||||
r'$in': ['messaging:${StreamChannel.of(context).channel.id}']
|
||||
r'$in': [StreamChannel.of(context).channel.cid]
|
||||
}
|
||||
},
|
||||
messageFilter: {
|
||||
@@ -146,7 +146,7 @@ class _ChannelFileDisplayScreenState extends State<ChannelFileDisplayScreen> {
|
||||
onEndOfPage: () => messageSearchBloc.loadMore(
|
||||
filter: {
|
||||
'cid': {
|
||||
r'$in': ['messaging:${StreamChannel.of(context).channel.id}']
|
||||
r'$in': [StreamChannel.of(context).channel.cid]
|
||||
}
|
||||
},
|
||||
messageFilter: {
|
||||
|
||||
@@ -44,7 +44,7 @@ class _ChannelMediaDisplayScreenState extends State<ChannelMediaDisplayScreen> {
|
||||
messageSearchBloc.search(
|
||||
filter: {
|
||||
'cid': {
|
||||
r'$in': ['messaging:${StreamChannel.of(context).channel.id}']
|
||||
r'$in': [StreamChannel.of(context).channel.cid],
|
||||
}
|
||||
},
|
||||
messageFilter: {
|
||||
@@ -169,7 +169,7 @@ class _ChannelMediaDisplayScreenState extends State<ChannelMediaDisplayScreen> {
|
||||
onEndOfPage: () => messageSearchBloc.loadMore(
|
||||
filter: {
|
||||
'cid': {
|
||||
r'$in': ['messaging:${StreamChannel.of(context).channel.id}']
|
||||
r'$in': [StreamChannel.of(context).channel.cid]
|
||||
}
|
||||
},
|
||||
messageFilter: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: 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.
|
||||
version: 1.3.0-beta
|
||||
version: 1.3.1-beta
|
||||
repository: https://github.com/GetStream/stream-chat-flutter
|
||||
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## 1.3.1-beta
|
||||
|
||||
* Update llc dependency
|
||||
|
||||
## 1.3.0-beta
|
||||
|
||||
* Update llc dependency
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: stream_chat_flutter_core
|
||||
homepage: https://github.com/GetStream/stream-chat-flutter
|
||||
description: Stream Chat official Flutter SDK Core. Build your own chat experience using Dart and Flutter.
|
||||
version: 1.3.0-beta
|
||||
version: 1.3.1-beta
|
||||
repository: https://github.com/GetStream/stream-chat-flutter
|
||||
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
|
||||
|
||||
@@ -10,7 +10,7 @@ environment:
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
stream_chat: ^1.3.0-beta
|
||||
stream_chat: ^1.3.1-beta
|
||||
flutter:
|
||||
sdk: flutter
|
||||
rxdart: ^0.25.0
|
||||
|
||||
Reference in New Issue
Block a user