Merge branch 'develop' of https://github.com/GetStream/stream-chat-flutter into feat/attachment_downloader

This commit is contained in:
Sahil Kumar
2021-03-02 14:23:27 +05:30
26 changed files with 156 additions and 42 deletions
+2
View File
@@ -10,6 +10,8 @@ assignees: ''
**Describe the bug**
A clear and concise description of what the bug is.
**What package are you using? What version?**
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
+1 -1
View File
@@ -9,7 +9,7 @@
**Quick Links**
- [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat
- [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/)
- [Flutter Chat SDK Tutorial](https://getstream.io/chat/flutter/tutorial/)
- [Chat UI Kit](https://getstream.io/chat/ui-kit/)
- [Sample apps](https://github.com/GetStream/flutter-samples)
+11
View File
@@ -1,3 +1,14 @@
## 1.3.1-beta
- Debounced frequent db calls
## 1.3.0-beta
- Save pinned messages in offline storage
- Minor fixes
- `StreamClient.QueryChannels` now returns a Stream and fetches the channels from storage before calling the api
- Added `StreamClient.QueryChannelsOnline` and `StreamClient.QueryChannelsOffline` to fetch channels only from online or offline
## 1.2.0-beta
- 🛑 **BREAKING** Changed signature of `StreamClient.search` method
+16 -5
View File
@@ -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)));
+3 -3
View File
@@ -350,7 +350,7 @@ class StreamChatClient {
Map<String, String> get _httpHeaders => {
'Authorization': token,
'stream-auth-type': _authType,
'x-stream-client': _userAgent,
'X-Stream-Client': _userAgent,
'Content-Encoding': 'gzip',
};
@@ -468,9 +468,9 @@ class StreamChatClient {
user: state.user,
connectParams: {
'api_key': apiKey,
'authorization': token,
'Authorization': token,
'stream-auth-type': _authType,
'x-stream-client': _userAgent,
'X-Stream-Client': _userAgent,
},
connectPayload: {
'user_id': state.user.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,26 +2,56 @@ import 'platform_detector_stub.dart'
if (dart.library.html) 'platform_detector_web.dart'
if (dart.library.io) 'platform_detector_io.dart';
/// Possible platforms
enum PlatformType {
///
Android,
///
Ios,
///
Web,
///
MacOS,
///
Windows,
///
Linux,
///
Fuchsia,
}
/// Utility class that provides information on the current platform
class CurrentPlatform {
CurrentPlatform._();
/// True if the app is running on android
static bool get isAndroid => type == PlatformType.Android;
/// True if the app is running on ios
static bool get isIos => type == PlatformType.Ios;
/// True if the app is running on web
static bool get isWeb => type == PlatformType.Web;
/// True if the app is running on macos
static bool get isMacOS => type == PlatformType.MacOS;
/// True if the app is running on windows
static bool get isWindows => type == PlatformType.Windows;
/// True if the app is running on linux
static bool get isLinux => type == PlatformType.Linux;
/// True if the app is running on fuchsia
static bool get isFuchsia => type == PlatformType.Fuchsia;
/// Returns a string version of the platform
static String get name {
switch (type) {
case PlatformType.Android:
@@ -43,5 +73,6 @@ class CurrentPlatform {
}
}
/// Get current platform type
static PlatformType get type => currentPlatform;
}
@@ -1,6 +1,7 @@
import 'dart:io';
import 'platform_detector.dart';
/// Version running on native systems
PlatformType get currentPlatform {
if (Platform.isWindows) return PlatformType.Windows;
if (Platform.isFuchsia) return PlatformType.Fuchsia;
@@ -1,5 +1,6 @@
import 'platform_detector.dart';
/// Stub implementation
PlatformType get currentPlatform {
throw UnimplementedError();
}
@@ -1,3 +1,4 @@
import 'platform_detector.dart';
/// Version running on web
PlatformType get currentPlatform => PlatformType.Web;
+2 -2
View File
@@ -1,5 +1,5 @@
import 'package:stream_chat/src/client.dart';
/// Current package version
/// Used in [StreamChatClient] to build the `x-stream-client` header
const PACKAGE_VERSION = '1.2.0-beta';
/// Used in [StreamChatClient] to build the `X-Stream-Client` header
const PACKAGE_VERSION = '1.3.1-beta';
+1 -1
View File
@@ -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.2.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
+15 -1
View File
@@ -1,7 +1,21 @@
## 1.3.1-beta
- Updated `stream_chat_core` dependency
- Fixed minor bugs
## 1.3.0-beta
- Added `MessageInputTheme`
- Fixed overflow in `MessageInput` animation
- Delete only image on imagegallery
- Close keyboard after sending a command
- Exposed `customAttachmentBuilders` through `MessageListView`
- 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
@@ -25,8 +25,7 @@ dependencies:
sdk: flutter
stream_chat_flutter:
path: ../
stream_chat_persistence:
path: ../../stream_chat_persistence
stream_chat_persistence: ^1.3.0-beta
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
@@ -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: {
@@ -1,6 +1,3 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
@@ -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: {
@@ -845,7 +845,9 @@ class ChannelHeaderTheme {
}
}
/// Defines the theme dedicated to the [MessageInput] widget
class MessageInputTheme {
/// Duration of the [MessageInput] send button animation
final Duration sendAnimationDuration;
/// Background color of [MessageInput] send button
@@ -863,6 +865,7 @@ class MessageInputTheme {
/// Background color of [MessageInput]
final Color inputBackground;
/// Returns a new [MessageInputTheme]
const MessageInputTheme({
this.sendAnimationDuration,
this.actionButtonColor,
@@ -872,6 +875,7 @@ class MessageInputTheme {
this.inputBackground,
});
/// Returns a new [MessageInputTheme] replacing some of its properties
MessageInputTheme copyWith({
Duration sendAnimationDuration,
Color inputBackground,
@@ -891,6 +895,7 @@ class MessageInputTheme {
sendButtonIdleColor: sendButtonIdleColor ?? this.sendButtonIdleColor,
);
/// Merges [this] [MessageInputTheme] with the [other]
MessageInputTheme merge(MessageInputTheme other) {
if (other == null) return this;
return copyWith(
@@ -56,19 +56,20 @@ class SystemMessage extends StatelessWidget {
onMessageTap(message);
}
},
child: Container(
width: double.infinity,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
divider,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
divider,
Flexible(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
message.text,
softWrap: true,
style: TextStyle(
fontSize: 10,
color: Theme.of(context)
@@ -107,9 +108,9 @@ class SystemMessage extends StatelessWidget {
],
),
),
divider,
],
),
),
divider,
],
),
);
}
+2 -2
View File
@@ -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.2.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
@@ -11,7 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
stream_chat_flutter_core: ^1.2.0-beta
stream_chat_flutter_core: ^1.3.0-beta
flutter_app_badger: ^1.1.2
photo_view: ^0.10.3
rxdart: ^0.25.0
@@ -1,3 +1,12 @@
## 1.3.1-beta
* Update llc dependency
## 1.3.0-beta
* Update llc dependency
* Minor fixes
## 1.2.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.2.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.2.0-beta
stream_chat: ^1.3.1-beta
flutter:
sdk: flutter
rxdart: ^0.25.0
@@ -1,3 +1,7 @@
## 1.3.0-beta
* Update llc dependency
## 1.2.0-beta
* Update llc dependency
@@ -11,8 +11,7 @@ dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
stream_chat:
path: ../../stream_chat
stream_chat: ^1.3.0
stream_chat_persistence:
path: ../
@@ -1,7 +1,7 @@
name: stream_chat_persistence
homepage: https://github.com/GetStream/stream-chat-flutter
description: Official Stream Chat Persistence library. Build your own chat experience using Dart and Flutter.
version: 1.2.0-beta
version: 1.3.0-beta
repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -13,8 +13,7 @@ dependencies:
path: ^1.7.0
path_provider: ^1.6.27
sqlite3_flutter_libs: ^0.4.0+1
stream_chat:
path: ../stream_chat
stream_chat: ^1.3.0-beta
dev_dependencies:
test: ^1.15.7