Merge branch 'develop' into v4
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
- Minor fixes and improvements.
|
||||
|
||||
## Upcoming
|
||||
## 3.6.0
|
||||
|
||||
🐞 Fixed
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
channel update.
|
||||
- [[#1054]](https://github.com/GetStream/stream-chat-flutter/issues/1054) Fix `Unsupported operation: Cannot remove from an unmodifiable list`.
|
||||
- [[#1033]](https://github.com/GetStream/stream-chat-flutter/issues/1033) Hard delete from dashboard does not delete message from client.
|
||||
- Send only `user_id` while reconnecting.
|
||||
|
||||
✅ Added
|
||||
|
||||
- Handle `event.message` in `channel.truncate` events
|
||||
- Added additional parameters to `channel.truncate`
|
||||
|
||||
## 3.5.1
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -265,11 +265,18 @@ class ChannelApi {
|
||||
/// Removes all messages from the channel
|
||||
Future<EmptyResponse> truncateChannel(
|
||||
String channelId,
|
||||
String channelType,
|
||||
) async {
|
||||
String channelType, {
|
||||
Message? message,
|
||||
bool? skipPush,
|
||||
DateTime? truncatedAt,
|
||||
}) async {
|
||||
final response = await _client.post(
|
||||
'${_getChannelUrl(channelId, channelType)}/truncate',
|
||||
data: {},
|
||||
data: {
|
||||
if (message != null) 'message': message,
|
||||
if (skipPush != null) 'skip_push': skipPush,
|
||||
if (truncatedAt != null) 'truncated_at': truncatedAt,
|
||||
},
|
||||
);
|
||||
return EmptyResponse.fromJson(response.data);
|
||||
}
|
||||
|
||||
@@ -147,12 +147,15 @@ class WebSocket with TimerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Uri> _buildUri({bool refreshToken = false}) async {
|
||||
Future<Uri> _buildUri({
|
||||
bool refreshToken = false,
|
||||
bool includeUserDetails = true,
|
||||
}) async {
|
||||
final user = _user!;
|
||||
final token = await tokenManager.loadToken(refresh: refreshToken);
|
||||
final params = {
|
||||
'user_id': user.id,
|
||||
'user_details': user,
|
||||
if (includeUserDetails) 'user_details': user,
|
||||
'user_token': token.rawValue,
|
||||
'server_determines_connection_id': true,
|
||||
};
|
||||
@@ -176,7 +179,10 @@ class WebSocket with TimerHelper {
|
||||
bool _connectRequestInProgress = false;
|
||||
|
||||
/// Connect the WS using the parameters passed in the constructor
|
||||
Future<Event> connect(User user) async {
|
||||
Future<Event> connect(
|
||||
User user, {
|
||||
bool includeUserDetails = false,
|
||||
}) async {
|
||||
if (_connectRequestInProgress) {
|
||||
throw const StreamWebSocketError('''
|
||||
You've called connect twice,
|
||||
@@ -191,7 +197,9 @@ class WebSocket with TimerHelper {
|
||||
connectionCompleter = Completer<Event>();
|
||||
|
||||
try {
|
||||
final uri = await _buildUri();
|
||||
final uri = await _buildUri(
|
||||
includeUserDetails: includeUserDetails,
|
||||
);
|
||||
_initWebSocketChannel(uri);
|
||||
} catch (e, stk) {
|
||||
_onConnectionError(e, stk);
|
||||
@@ -219,7 +227,10 @@ class WebSocket with TimerHelper {
|
||||
setTimer(
|
||||
Duration(milliseconds: delay),
|
||||
() async {
|
||||
final uri = await _buildUri(refreshToken: refreshToken);
|
||||
final uri = await _buildUri(
|
||||
refreshToken: refreshToken,
|
||||
includeUserDetails: false,
|
||||
);
|
||||
try {
|
||||
_initWebSocketChannel(uri);
|
||||
} catch (e, stk) {
|
||||
|
||||
@@ -124,7 +124,10 @@ class FakeWebSocket extends Fake implements WebSocket {
|
||||
Completer<Event>? connectionCompleter;
|
||||
|
||||
@override
|
||||
Future<Event> connect(User user) async {
|
||||
Future<Event> connect(
|
||||
User user, {
|
||||
bool? includeUserDetails = true,
|
||||
}) async {
|
||||
connectionStatus = ConnectionStatus.connecting;
|
||||
final event = Event(
|
||||
type: EventType.healthCheck,
|
||||
@@ -167,7 +170,10 @@ class FakeWebSocketWithConnectionError extends Fake implements WebSocket {
|
||||
Completer<Event>? connectionCompleter;
|
||||
|
||||
@override
|
||||
Future<Event> connect(User user) async {
|
||||
Future<Event> connect(
|
||||
User user, {
|
||||
bool? includeUserDetails = true,
|
||||
}) async {
|
||||
connectionStatus = ConnectionStatus.connecting;
|
||||
const error = StreamWebSocketError('Error Connecting');
|
||||
connectionCompleter = Completer()..completeError(error);
|
||||
|
||||
Reference in New Issue
Block a user