Merge branch 'develop' into v4

This commit is contained in:
Salvatore Giordano
2022-04-13 14:31:44 +02:00
17 changed files with 427 additions and 46 deletions
@@ -1055,10 +1055,23 @@ class Channel {
return _client.deleteChannel(id!, type);
}
/// Removes all messages from the channel.
Future<EmptyResponse> truncate() async {
/// Removes all messages from the channel up to [truncatedAt] or now if
/// [truncatedAt] is not provided.
/// If [skipPush] is true, no push notification will be sent.
/// [Message] is the system message that will be sent to the channel.
Future<EmptyResponse> truncate({
Message? message,
bool? skipPush,
DateTime? truncatedAt,
}) async {
_checkInitialized();
return _client.truncateChannel(id!, type);
return _client.truncateChannel(
id!,
type,
message: message,
skipPush: skipPush,
truncatedAt: truncatedAt,
);
}
/// Accept invitation to the channel.
@@ -328,7 +328,9 @@ class StreamChatClient {
_chatPersistenceClient = _originalChatPersistenceClient;
await _chatPersistenceClient!.connect(ownUser.id);
}
final connectedUser = await openConnection();
final connectedUser = await openConnection(
includeUserDetailsInConnectCall: true,
);
return state.currentUser = connectedUser;
} catch (e, stk) {
if (e is StreamWebSocketError && e.isRetriable) {
@@ -341,7 +343,11 @@ class StreamChatClient {
}
/// Creates a new WebSocket connection with the current user.
Future<OwnUser> openConnection() async {
/// If [includeUserDetailsInConnectCall] is true it will include the current
/// user details in the connect call.
Future<OwnUser> openConnection({
bool includeUserDetailsInConnectCall = false,
}) async {
assert(
state.currentUser != null,
'User is not set on client, '
@@ -371,7 +377,10 @@ class StreamChatClient {
_ws.connectionStatusStream.skip(1).listen(_connectionStatusHandler);
try {
final event = await _ws.connect(user);
final event = await _ws.connect(
user,
includeUserDetails: includeUserDetailsInConnectCall,
);
return user.merge(event.me);
} catch (e, stk) {
logger.severe('error connecting ws', e, stk);
@@ -940,14 +949,23 @@ class StreamChatClient {
channelType,
);
/// Removes all messages from the channel
/// Removes all messages from the channel up to [truncatedAt] or now if
/// [truncatedAt] is not provided.
/// If [skipPush] is true, no push notification will be sent.
/// [Message] is the system message that will be sent to the channel.
Future<EmptyResponse> truncateChannel(
String channelId,
String channelType,
) =>
String channelType, {
Message? message,
bool? skipPush,
DateTime? truncatedAt,
}) =>
_chatApi.channel.truncateChannel(
channelId,
channelType,
message: message,
skipPush: skipPush,
truncatedAt: truncatedAt,
);
/// Mutes the channel