rename Client to StreamChatClient
This commit is contained in:
@@ -160,8 +160,8 @@ class Channel {
|
||||
state?.channelStateStream?.map((cs) => cs.channel?.extraData);
|
||||
|
||||
/// The main Stream chat client
|
||||
Client get client => _client;
|
||||
final Client _client;
|
||||
StreamChatClient get client => _client;
|
||||
final StreamChatClient _client;
|
||||
|
||||
String get _channelURL => '/channels/$type/$id';
|
||||
|
||||
@@ -722,7 +722,7 @@ class Channel {
|
||||
});
|
||||
}
|
||||
|
||||
/// Hides the channel from [Client.queryChannels] for the user until a message is added
|
||||
/// Hides the channel from [StreamChatClient.queryChannels] for the user until a message is added
|
||||
/// If [clearHistory] is set to true - all messages will be removed for the user
|
||||
Future<EmptyResponse> hide({bool clearHistory = false}) async {
|
||||
_checkInitialized();
|
||||
|
||||
@@ -17,7 +17,7 @@ class _BaseResponse {
|
||||
String duration;
|
||||
}
|
||||
|
||||
/// Model response for [Client.resync] api call
|
||||
/// Model response for [StreamChatClient.resync] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SyncResponse extends _BaseResponse {
|
||||
/// The list of events
|
||||
@@ -28,7 +28,7 @@ class SyncResponse extends _BaseResponse {
|
||||
_$SyncResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryChannels] api call
|
||||
/// Model response for [StreamChatClient.queryChannels] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryChannelsResponse extends _BaseResponse {
|
||||
/// List of channels state returned by the query
|
||||
@@ -39,7 +39,7 @@ class QueryChannelsResponse extends _BaseResponse {
|
||||
_$QueryChannelsResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryChannels] api call
|
||||
/// Model response for [StreamChatClient.queryChannels] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class TranslateMessageResponse extends _BaseResponse {
|
||||
/// List of channels state returned by the query
|
||||
@@ -50,7 +50,7 @@ class TranslateMessageResponse extends _BaseResponse {
|
||||
_$TranslateMessageResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryChannels] api call
|
||||
/// Model response for [StreamChatClient.queryChannels] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryMembersResponse extends _BaseResponse {
|
||||
/// List of channels state returned by the query
|
||||
@@ -61,7 +61,7 @@ class QueryMembersResponse extends _BaseResponse {
|
||||
_$QueryMembersResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.queryUsers] api call
|
||||
/// Model response for [StreamChatClient.queryUsers] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class QueryUsersResponse extends _BaseResponse {
|
||||
/// List of users returned by the query
|
||||
@@ -94,7 +94,7 @@ class QueryRepliesResponse extends _BaseResponse {
|
||||
_$QueryRepliesResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.getDevices] api call
|
||||
/// Model response for [StreamChatClient.getDevices] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class ListDevicesResponse extends _BaseResponse {
|
||||
/// List of user devices
|
||||
@@ -141,7 +141,7 @@ class SendReactionResponse extends _BaseResponse {
|
||||
_$SendReactionResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.setGuestUser] api call
|
||||
/// Model response for [StreamChatClient.setGuestUser] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SetGuestUserResponse extends _BaseResponse {
|
||||
/// Guest user access token
|
||||
@@ -155,7 +155,7 @@ class SetGuestUserResponse extends _BaseResponse {
|
||||
_$SetGuestUserResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.updateUser] api call
|
||||
/// Model response for [StreamChatClient.updateUser] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class UpdateUsersResponse extends _BaseResponse {
|
||||
/// Updated users
|
||||
@@ -166,7 +166,7 @@ class UpdateUsersResponse extends _BaseResponse {
|
||||
_$UpdateUsersResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.updateMessage] api call
|
||||
/// Model response for [StreamChatClient.updateMessage] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class UpdateMessageResponse extends _BaseResponse {
|
||||
/// Message returned by the api call
|
||||
@@ -188,7 +188,7 @@ class SendMessageResponse extends _BaseResponse {
|
||||
_$SendMessageResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Client.getMessage] api call
|
||||
/// Model response for [StreamChatClient.getMessage] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class GetMessageResponse extends _BaseResponse {
|
||||
/// Message returned by the api call
|
||||
@@ -208,7 +208,7 @@ class GetMessageResponse extends _BaseResponse {
|
||||
}
|
||||
}
|
||||
|
||||
/// Model response for [Client.search] api call
|
||||
/// Model response for [StreamChatClient.search] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SearchMessagesResponse extends _BaseResponse {
|
||||
/// List of messages returned by the api call
|
||||
|
||||
@@ -15,17 +15,18 @@ class RetryPolicy {
|
||||
int attempt = 0;
|
||||
|
||||
/// This function evaluates if we should retry the failure
|
||||
final bool Function(Client client, int attempt, ApiError apiError)
|
||||
final bool Function(StreamChatClient client, int attempt, ApiError apiError)
|
||||
shouldRetry;
|
||||
|
||||
/// In the case that we want to retry a failed request the retryTimeout method is called to determine the timeout
|
||||
final Duration Function(Client client, int attempt, ApiError apiError)
|
||||
retryTimeout;
|
||||
final Duration Function(
|
||||
StreamChatClient client, int attempt, ApiError apiError) retryTimeout;
|
||||
|
||||
/// Creates a copy of [RetryPolicy] with specified attributes overridden.
|
||||
RetryPolicy copyWith({
|
||||
bool Function(Client client, int attempt, ApiError apiError) shouldRetry,
|
||||
Duration Function(Client client, int attempt, ApiError apiError)
|
||||
bool Function(StreamChatClient client, int attempt, ApiError apiError)
|
||||
shouldRetry,
|
||||
Duration Function(StreamChatClient client, int attempt, ApiError apiError)
|
||||
retryTimeout,
|
||||
int attempt,
|
||||
}) =>
|
||||
|
||||
@@ -3,15 +3,15 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:pedantic/pedantic.dart' show unawaited;
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:stream_chat/src/api/retry_policy.dart';
|
||||
import 'package:stream_chat/src/event_type.dart';
|
||||
import 'package:stream_chat/src/models/own_user.dart';
|
||||
import 'package:stream_chat/version.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:pedantic/pedantic.dart' show unawaited;
|
||||
|
||||
import 'api/channel.dart';
|
||||
import 'api/connection_status.dart';
|
||||
@@ -64,12 +64,12 @@ extension on PushProvider {
|
||||
/// websocket connection to Stream Chat servers.
|
||||
///
|
||||
/// ```dart
|
||||
/// final client = Client("stream-chat-api-key");
|
||||
/// final client = StreamChatClient("stream-chat-api-key");
|
||||
/// ```
|
||||
class Client {
|
||||
class StreamChatClient {
|
||||
/// Create a client instance with default options.
|
||||
/// You should only create the client once and re-use it across your application.
|
||||
Client(
|
||||
StreamChatClient(
|
||||
this.apiKey, {
|
||||
this.tokenProvider,
|
||||
this.baseURL = _defaultBaseURL,
|
||||
@@ -81,9 +81,10 @@ class Client {
|
||||
RetryPolicy retryPolicy,
|
||||
}) {
|
||||
_retryPolicy ??= RetryPolicy(
|
||||
retryTimeout: (Client client, int attempt, ApiError error) =>
|
||||
retryTimeout: (StreamChatClient client, int attempt, ApiError error) =>
|
||||
Duration(seconds: 1 * attempt),
|
||||
shouldRetry: (Client client, int attempt, ApiError error) => attempt < 5,
|
||||
shouldRetry: (StreamChatClient client, int attempt, ApiError error) =>
|
||||
attempt < 5,
|
||||
);
|
||||
|
||||
state = ClientState(this);
|
||||
@@ -94,7 +95,7 @@ class Client {
|
||||
logger.info('instantiating new client');
|
||||
}
|
||||
|
||||
/// Client chat persistence client
|
||||
/// Chat persistence client
|
||||
ChatPersistenceClient chatPersistenceClient;
|
||||
|
||||
/// Whether the chat persistence is available or not
|
||||
@@ -110,11 +111,11 @@ class Client {
|
||||
/// This client state
|
||||
ClientState state;
|
||||
|
||||
/// By default the Chat Client will write all messages with level Warn or Error to stdout.
|
||||
/// By default the Chat client will write all messages with level Warn or Error to stdout.
|
||||
/// During development you might want to enable more logging information, you can change the default log level when constructing the client.
|
||||
///
|
||||
/// ```dart
|
||||
/// final client = Client("stream-chat-api-key", logLevel: Level.INFO);
|
||||
/// final client = StreamChatClient("stream-chat-api-key", logLevel: Level.INFO);
|
||||
/// ```
|
||||
final Level logLevel;
|
||||
|
||||
@@ -133,7 +134,7 @@ class Client {
|
||||
/// // do something with the record (ie. send it to Sentry or Fabric)
|
||||
/// }
|
||||
///
|
||||
/// final client = Client("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
|
||||
/// final client = StreamChatClient("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
|
||||
///```
|
||||
LogHandlerFunction logHandlerFunction;
|
||||
|
||||
@@ -1337,7 +1338,7 @@ class ClientState {
|
||||
}));
|
||||
}
|
||||
|
||||
final Client _client;
|
||||
final StreamChatClient _client;
|
||||
|
||||
/// Update user information
|
||||
set user(OwnUser user) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:stream_chat/src/client.dart';
|
||||
|
||||
/// Current package version
|
||||
/// Used in [Client] to build the `x-stream-client` header
|
||||
/// Used in [StreamChatClient] to build the `x-stream-client` header
|
||||
const PACKAGE_VERSION = '0.2.24+2';
|
||||
|
||||
Reference in New Issue
Block a user