Merge branch 'develop' into v4

This commit is contained in:
Salvatore Giordano
2022-01-25 11:40:02 +01:00
24 changed files with 333 additions and 232 deletions
@@ -66,8 +66,11 @@ class StreamChatClient {
this.logLevel = Level.WARNING,
LogHandlerFunction? logHandlerFunction,
RetryPolicy? retryPolicy,
Location? location,
@Deprecated('Use location to change baseUrl instead') String? baseURL,
@Deprecated('''
Location is now deprecated in favor of the new edge server. Will be removed in v4.0.0.
Read more here: https://getstream.io/blog/chat-edge-infrastructure
''') Location? location,
String? baseURL,
Duration connectTimeout = const Duration(seconds: 6),
Duration receiveTimeout = const Duration(seconds: 6),
StreamChatApi? chatApi,
@@ -79,7 +82,6 @@ class StreamChatClient {
final options = StreamHttpClientOptions(
baseUrl: baseURL,
location: location,
connectTimeout: connectTimeout,
receiveTimeout: receiveTimeout,
headers: {'X-Stream-Client': defaultUserAgent},
@@ -11,7 +11,6 @@ import 'package:stream_chat/src/core/http/interceptor/connection_id_interceptor.
import 'package:stream_chat/src/core/http/interceptor/logging_interceptor.dart';
import 'package:stream_chat/src/core/http/stream_chat_dio_error.dart';
import 'package:stream_chat/src/core/http/token_manager.dart';
import 'package:stream_chat/src/location.dart';
part 'stream_http_client_options.dart';
@@ -1,32 +1,20 @@
part of 'stream_http_client.dart';
const _defaultBaseURL = 'https://chat-us-east-1.stream-io-api.com';
const _defaultBaseURL = 'https://chat.stream-io-api.com';
/// Client options to modify [StreamHttpClient]
class StreamHttpClientOptions {
/// Instantiates a new [StreamHttpClientOptions]
const StreamHttpClientOptions({
String? baseUrl,
this.location,
this.connectTimeout = const Duration(seconds: 6),
this.receiveTimeout = const Duration(seconds: 6),
this.queryParameters = const {},
this.headers = const {},
}) : _baseUrl = baseUrl ?? _defaultBaseURL;
final String _baseUrl;
}) : baseUrl = baseUrl ?? _defaultBaseURL;
/// base url to use with client.
String get baseUrl {
if (location == null) return _baseUrl;
const serviceName = 'chat';
final locationName = location!.name;
const baseDomainName = 'stream-io-api.com';
return 'https://$serviceName-proxy-$locationName.$baseDomainName';
}
/// data center to use with client
final Location? location;
final String baseUrl;
/// connect timeout, default to 6s
final Duration connectTimeout;
@@ -1,6 +1,4 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:stream_chat/src/core/models/channel_model.dart';
import 'package:stream_chat/src/core/models/message.dart';
import 'package:stream_chat/src/core/util/serializer.dart';
import 'package:stream_chat/stream_chat.dart';
@@ -1,7 +1,4 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:stream_chat/src/core/models/device.dart';
import 'package:stream_chat/src/core/models/mute.dart';
import 'package:stream_chat/src/core/models/user.dart';
import 'package:stream_chat/src/core/util/serializer.dart';
import 'package:stream_chat/stream_chat.dart';
@@ -89,9 +86,9 @@ class OwnUser extends User {
OwnUser(
id: id ?? this.id,
role: role ?? this.role,
/* if null, it will be retrieved from extraData['name']*/
// if null, it will be retrieved from extraData['name']
name: name,
/* if null, it will be retrieved from extraData['image']*/
// if null, it will be retrieved from extraData['image']
image: image,
banned: banned ?? this.banned,
createdAt: createdAt ?? this.createdAt,
@@ -139,7 +136,7 @@ class OwnUser extends User {
@JsonKey(includeIfNull: false)
final List<Mute> mutes;
/// List of users muted by the user.
/// List of channels muted by the user.
@JsonKey(includeIfNull: false)
final List<Mute> channelMutes;
@@ -45,7 +45,7 @@ class User extends Equatable {
this.language,
}) : createdAt = createdAt ?? DateTime.now(),
updatedAt = updatedAt ?? DateTime.now(),
/*For backwards compatibility, set 'name', 'image' in [extraData].*/
// For backwards compatibility, set 'name', 'image' in [extraData].
extraData = {
...extraData,
if (name != null) 'name': name,
@@ -164,9 +164,9 @@ class User extends Equatable {
User(
id: id ?? this.id,
role: role ?? this.role,
/* if null, it will be retrieved from extraData['name']*/
// if null, it will be retrieved from extraData['name']
name: name,
/* if null, it will be retrieved from extraData['image']*/
// if null, it will be retrieved from extraData['image']
image: image,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,